Skip to content

Commit

Permalink
feat: add basic testing infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed Aug 6, 2023
1 parent 4969b83 commit 4aaea00
Show file tree
Hide file tree
Showing 17 changed files with 525,792 additions and 10 deletions.
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,31 @@ zorbash.exe.dSYM
zorbash.pdb
zorbash.sh
Zorbash-*-windows-x64-installer.exe
tests/apecastle/expected_output/console
tests/apecastle/output/
tests/badmonkey/expected_output/console
tests/badmonkey/output/
tests/deathpool/expected_output/console
tests/deathpool/output/
tests/discobob/expected_output/console
tests/discobob/output/
tests/drakestone/expected_output/console
tests/drakestone/output/
tests/goblinhack/expected_output/console
tests/goblinhack/output/
tests/hearthstone/expected_output/console
tests/hearthstone/output/
tests/hellfire/expected_output/console
tests/hellfire/output/
tests/pondscum/expected_output/console
tests/pondscum/output/
tests/seadragon/expected_output/console
tests/seadragon/output/
tests/snowdrop/expected_output/console
tests/snowdrop/output/
tests/terrorlake/expected_output/console
tests/terrorlake/output/
tests/umbermonk/expected_output/console
tests/umbermonk/output/
tests/victimlake/expected_output/console
tests/victimlake/output/
27 changes: 19 additions & 8 deletions TESTME
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ if [ ! -x zorbash ]; then
fi

for seed in \
charliebats \
dogmanlives \
grayalien \
cavemire \
castlespire \
donkeyking \
alphabase \
seadragon \
terrorlake \
badmonkey \
snowdrop \
firebelow \
umbermonk \
discobob \
drakestone \
Expand All @@ -45,27 +51,32 @@ for seed in \
victimlake
do
mkdir -p tests/$seed/output/
mkdir -p tests/$seed/expected_output
mkdir -p tests/$seed/expected_output/

printf "%-60s ... " "Running seed ($seed)"
./zorbash --debug --seed $seed --test-dungeon-gen --ascii --monochrome > tests/$seed/output/console
cp appdata/zorbash/stdout* tests/$seed/output/
./zorbash --seed $seed --test-dungeon-gen --ascii --monochrome > tests/$seed/output/console
cp appdata/zorbash/stdout.txt tests/$seed/output/

grep -q ERROR appdata/zorbash/*
if [ $? -eq 0 ]; then
printf "$RED[%s]$RESET\n" "ERROR"
continue
fi

# ls -lahsi tests/$seed/output/stdout.txt
if [ ! -f tests/$seed/expected_output/stdout.txt ]; then
cp -r tests/$seed/output/* tests/$seed/expected_output
printf "$GREEN[%s]$RESET\n" "CREATED"
cp -r tests/$seed/output/stdout.txt tests/$seed/expected_output/
moves=$(grep "End of test, move count:" tests/$seed/output/stdout.txt | sed 's/.*://g')
printf "$GREEN[%s]$RESET (%s moves)\n" "CREATED" $moves
else
diff -q tests/$seed/output/stdout.txt tests/$seed/expected_output/stdout.txt
if [ $? -ne 0 ]; then
printf "$RED[%s]$RESET\n" "CHANGED"
moves=$(grep "End of test, move count:" tests/$seed/output/stdout.txt | sed 's/.*://g')
expected_moves=$(grep "End of test, move count:" tests/$seed/expected_output/stdout.txt | sed 's/.*://g')
printf "$RED[%s]$RESET (%s moves expected, found %s)\n" "CHANGED" $expected_moves $moves
else
printf "$GREEN[%s]$RESET\n" "OK"
moves=$(grep "End of test, move count:" tests/$seed/output/stdout.txt | sed 's/.*://g')
printf "$GREEN[%s]$RESET %s moves\n" "OK" $moves
fi
fi
done
6 changes: 4 additions & 2 deletions src/dungeon_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ void dungeon_test(void)
pcg_random_allowed--;
}

while (! game->level->player->is_dead) {
auto player = game->level->player;
while (! player->is_dead) {
TRACE_NO_INDENT();
SDL_Delay(5);

Expand All @@ -97,12 +98,13 @@ void dungeon_test(void)
wid_display_all();
}

CON("End of test, move count: %u", player->move_count());

TRACE_NO_INDENT();
delete new_level;

TRACE_NO_INDENT();
game->fini();

CON("end of test");
exit(0);
}
14,590 changes: 14,590 additions & 0 deletions tests/apecastle/expected_output/stdout.txt

Large diffs are not rendered by default.

18,608 changes: 18,608 additions & 0 deletions tests/badmonkey/expected_output/stdout.txt

Large diffs are not rendered by default.

8,896 changes: 8,896 additions & 0 deletions tests/deathpool/expected_output/stdout.txt

Large diffs are not rendered by default.

24,077 changes: 24,077 additions & 0 deletions tests/discobob/expected_output/stdout.txt

Large diffs are not rendered by default.

73,000 changes: 73,000 additions & 0 deletions tests/drakestone/expected_output/stdout.txt

Large diffs are not rendered by default.

15,002 changes: 15,002 additions & 0 deletions tests/goblinhack/expected_output/stdout.txt

Large diffs are not rendered by default.

44,392 changes: 44,392 additions & 0 deletions tests/hearthstone/expected_output/stdout.txt

Large diffs are not rendered by default.

54,691 changes: 54,691 additions & 0 deletions tests/hellfire/expected_output/stdout.txt

Large diffs are not rendered by default.

45,279 changes: 45,279 additions & 0 deletions tests/pondscum/expected_output/stdout.txt

Large diffs are not rendered by default.

49,118 changes: 49,118 additions & 0 deletions tests/seadragon/expected_output/stdout.txt

Large diffs are not rendered by default.

54,888 changes: 54,888 additions & 0 deletions tests/snowdrop/expected_output/stdout.txt

Large diffs are not rendered by default.

65,015 changes: 65,015 additions & 0 deletions tests/terrorlake/expected_output/stdout.txt

Large diffs are not rendered by default.

27,930 changes: 27,930 additions & 0 deletions tests/umbermonk/expected_output/stdout.txt

Large diffs are not rendered by default.

30,255 changes: 30,255 additions & 0 deletions tests/victimlake/expected_output/stdout.txt

Large diffs are not rendered by default.

0 comments on commit 4aaea00

Please sign in to comment.