Skip to content

Commit 67b4765

Browse files
committed
ags4-auto-test: tests may consist of multiple stages (and rooms)
1 parent e642441 commit 67b4765

File tree

4 files changed

+33
-78
lines changed

4 files changed

+33
-78
lines changed

ags4/auto-test/GlobalScript.asc

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,71 +19,9 @@ function repeatedly_execute_always()
1919
// called when a key is pressed
2020
function on_key_press(eKeyCode keycode, int mod)
2121
{
22-
if (IsGamePaused())
23-
{
24-
// game paused, so don't react to any keypresses
25-
keycode = 0;
26-
}
27-
else if (keycode == eKeyQ && (mod & eKeyModCtrl))
28-
{
29-
// Ctrl-Q will quit the game
30-
QuitGame(1);
31-
}
32-
else if (keycode == eKeyF9)
33-
{
34-
// F9 will restart the game
35-
RestartGame();
36-
}
37-
else if (keycode == eKeyF12)
38-
{
39-
// F12 will save a screenshot to the save game folder
40-
SaveScreenShot("screenshot.pcx");
41-
}
42-
else if (mod & eKeyModCtrl)
43-
{
44-
if (keycode == eKeyS)
45-
{
46-
// Ctrl-S will give the player all defined inventory items
47-
Debug(0, 0);
48-
}
49-
else if (keycode == eKeyV)
50-
{
51-
// Ctrl-V will show game engine version and build date
52-
Debug(1, 0);
53-
}
54-
else if (keycode == eKeyA)
55-
{
56-
// Ctrl-A will show walkable areas
57-
Debug(2, 3);
58-
}
59-
else if (keycode == eKeyX)
60-
{
61-
// Ctrl-X will let the player teleport to any room
62-
Debug(3, 0);
63-
}
64-
}
6522
}
6623

6724
// called when a mouse button is clicked
6825
function on_mouse_click(MouseButton button)
6926
{
70-
if (IsGamePaused())
71-
{
72-
// game is paused, so do nothing (i.e. don't process mouse clicks)
73-
}
74-
else if (button == eMouseLeft)
75-
{
76-
// left-click, so try using the current mouse cursor mode at this position
77-
Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
78-
}
79-
else if (button == eMouseRight)
80-
{
81-
// right-click, so cycle the mouse cursor mode
82-
mouse.SelectNextMode();
83-
}
84-
}
85-
86-
function dialog_request(int param)
87-
{
88-
8927
}

ags4/auto-test/Rooms/1/room1.asc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// room script file
22
// Room1.asc
33
//
4-
// This room runs all tests
4+
// This room runs the stage 1 tests
55

66
function room_AfterFadeIn()
77
{
8-
RunTests();
8+
BeginTests();
9+
RunStage1Tests();
10+
FinishTests();
911
}

ags4/auto-test/run-tests.asc

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// new module script
22

3-
void RunTests()
3+
int TotalTestCount;
4+
5+
void BeginTests()
46
{
57
int test_count = 0;
68
test_count += GetTestMathsCount();
@@ -16,8 +18,29 @@ void RunTests()
1618
test_count += GetTestEngineRenderCount();
1719
test_count += GetTestPathfindingCount();
1820

21+
TotalTestCount = test_count;
22+
1923
tap.clean_test();
2024
tap.plan(test_count);
25+
}
26+
27+
void FinishTests()
28+
{
29+
tap.done_testing();
30+
31+
if (tap.AnyTestFailed()) {
32+
AbortGame("ERROR: test(s) have failed.");
33+
}
34+
35+
if (tap.PlannedTests != tap.ExecutedTests) {
36+
AbortGame("ERROR: Plan mismatch! Planned %d tests, but ran %d tests.", tap.PlannedTests, tap.ExecutedTests);
37+
}
38+
39+
QuitGame(0);
40+
}
41+
42+
void RunStage1Tests()
43+
{
2144
TestString();
2245
TestMaths();
2346
TestSet();
@@ -30,15 +53,4 @@ void RunTests()
3053
TestMisc();
3154
TestPathfinding();
3255
TestEngineRender();
33-
tap.done_testing();
34-
35-
if(tap.AnyTestFailed()) {
36-
AbortGame("ERROR: test(s) have failed.");
37-
}
38-
39-
if(tap.PlannedTests != tap.ExecutedTests) {
40-
AbortGame("ERROR: Plan mismatch! Planned %d tests, but ran %d tests.", tap.PlannedTests, tap.ExecutedTests);
41-
}
42-
43-
QuitGame(0);
44-
}
56+
}

ags4/auto-test/run-tests.ash

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
// new module header
2-
import void RunTests();
2+
import void BeginTests();
3+
import void FinishTests();
4+
5+
import void RunStage1Tests();

0 commit comments

Comments
 (0)