From f4351219084ecee7260f0f95831980a5bb4f977e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Porto?= Date: Sun, 26 Jan 2025 13:28:18 -0300 Subject: [PATCH] ags3,4: tap can check for plan mismatch at runtime the check isn't done in tap itself, but is made as part of run-tests for more flexibility --- ags3/auto-test/Game.agf | 10 +++++----- ags3/auto-test/run-tests.asc | 5 +++++ ags3/auto-test/tap.asc | 10 ++++++++++ ags3/auto-test/tap.ash | 6 ++++++ ags4/auto-test/Game.agf | 8 ++++---- ags4/auto-test/run-tests.asc | 5 +++++ ags4/auto-test/tap.asc | 10 ++++++++++ ags4/auto-test/tap.ash | 6 ++++++ 8 files changed, 51 insertions(+), 9 deletions(-) diff --git a/ags3/auto-test/Game.agf b/ags3/auto-test/Game.agf index 15fdf7a..729fdc4 100644 --- a/ags3/auto-test/Game.agf +++ b/ags3/auto-test/Game.agf @@ -1,6 +1,6 @@ - + False @@ -2190,10 +2190,10 @@ diff --git a/ags3/auto-test/run-tests.asc b/ags3/auto-test/run-tests.asc index 55cf2f0..cc29c8c 100644 --- a/ags3/auto-test/run-tests.asc +++ b/ags3/auto-test/run-tests.asc @@ -31,5 +31,10 @@ void RunTests() if(tap.AnyTestFailed()) { AbortGame("ERROR: test(s) have failed."); } + + if(tap.PlannedTests != tap.ExecutedTests) { + AbortGame("ERROR: Plan mismatch! Planned %d tests, but ran %d tests.", tap.PlannedTests, tap.ExecutedTests); + } + QuitGame(0); } \ No newline at end of file diff --git a/ags3/auto-test/tap.asc b/ags3/auto-test/tap.asc index 82476b5..d84466e 100644 --- a/ags3/auto-test/tap.asc +++ b/ags3/auto-test/tap.asc @@ -240,6 +240,16 @@ static void tap::Comment(String comment) { _test_printer(String.Format("# %s", comment)); } +int get_PlannedTests(static tap) +{ + return _planned_tests; +} + +int get_ExecutedTests(static tap) +{ + return _test_count - 1; +} + // refer to the game forum topic or github repository for updated current documentation. // the below text is only provided as a last resort in case you are offline. // diff --git a/ags3/auto-test/tap.ash b/ags3/auto-test/tap.ash index 9016a06..22a8663 100644 --- a/ags3/auto-test/tap.ash +++ b/ags3/auto-test/tap.ash @@ -56,4 +56,10 @@ struct tap{ /// add a comment to output import static void Comment(String comment); + + /// gets the number of tests that are planned + import static readonly attribute int PlannedTests; + + /// gets the number of tests executed so far + import static readonly attribute int ExecutedTests; }; diff --git a/ags4/auto-test/Game.agf b/ags4/auto-test/Game.agf index 462e9e1..e65804e 100644 --- a/ags4/auto-test/Game.agf +++ b/ags4/auto-test/Game.agf @@ -1726,10 +1726,10 @@ diff --git a/ags4/auto-test/run-tests.asc b/ags4/auto-test/run-tests.asc index 55cf2f0..cc29c8c 100644 --- a/ags4/auto-test/run-tests.asc +++ b/ags4/auto-test/run-tests.asc @@ -31,5 +31,10 @@ void RunTests() if(tap.AnyTestFailed()) { AbortGame("ERROR: test(s) have failed."); } + + if(tap.PlannedTests != tap.ExecutedTests) { + AbortGame("ERROR: Plan mismatch! Planned %d tests, but ran %d tests.", tap.PlannedTests, tap.ExecutedTests); + } + QuitGame(0); } \ No newline at end of file diff --git a/ags4/auto-test/tap.asc b/ags4/auto-test/tap.asc index 82476b5..d84466e 100644 --- a/ags4/auto-test/tap.asc +++ b/ags4/auto-test/tap.asc @@ -240,6 +240,16 @@ static void tap::Comment(String comment) { _test_printer(String.Format("# %s", comment)); } +int get_PlannedTests(static tap) +{ + return _planned_tests; +} + +int get_ExecutedTests(static tap) +{ + return _test_count - 1; +} + // refer to the game forum topic or github repository for updated current documentation. // the below text is only provided as a last resort in case you are offline. // diff --git a/ags4/auto-test/tap.ash b/ags4/auto-test/tap.ash index cab81a5..de69cba 100644 --- a/ags4/auto-test/tap.ash +++ b/ags4/auto-test/tap.ash @@ -56,4 +56,10 @@ struct tap{ /// add a comment to output import static void Comment(String comment); + + /// gets the number of tests that are planned + import static readonly attribute int PlannedTests; + + /// gets the number of tests executed so far + import static readonly attribute int ExecutedTests; };