-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move tests to snapshot-tests and enhance them (#141)
Snapshot tests kind of suck in general and are more fragile, but they are all we really have right now for testing before the unit test changes and they can still serve some purpose for doing end-to-end testing. This moves the directory to be better named, updates the github workflow to use the new directory/driver script and enhances that script to compare the output to 'expected' output each step of the way.
- Loading branch information
Showing
133 changed files
with
904,467 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
if [[ ! -f ../standard/standard ]]; then | ||
echo "Please build the standard executable before running the snapshot tests. Test failed." | ||
exit 1 | ||
fi | ||
|
||
cp ../standard/standard standard | ||
chmod +x ./standard | ||
|
||
lastTurn=$(<"turns/turn") | ||
|
||
for turn in $(seq 0 $lastTurn) | ||
do | ||
echo -n "Replaying turn $turn..." | ||
cp -f turns/turn_$turn/game.in game.in | ||
cp -f turns/turn_$turn/players.in players.in | ||
cp -f turns/turn_$turn/orders.3 orders.3 | ||
|
||
./standard run &> engine-output.txt | ||
if [[ $? != 0 ]]; then | ||
echo "executable crashed. -- Test failed." | ||
cat engine-output.txt | ||
rm -f game.* | ||
rm -f players.* | ||
rm -f times.* | ||
rm -f orders.* | ||
rm -f template.* | ||
rm -f report.* | ||
rm -f engine-output.txt | ||
rm -f ./standard | ||
exit 1 | ||
fi | ||
|
||
mkdir -p output/turn_$turn | ||
mv game.* output/turn_$turn | ||
mv players.* output/turn_$turn | ||
if [[ -f times.* ]]; then | ||
mv times.* output/turn_$turn | ||
fi | ||
mv orders.* output/turn_$turn | ||
mv template.* output/turn_$turn | ||
mv report.* output/turn_$turn | ||
mv engine-output.txt output/turn_$turn | ||
|
||
diff -ur turns/turn_$turn output/turn_$turn &> turn-difference.txt | ||
if [[ $? != 0 ]]; then | ||
echo "output differed. -- Test failed." | ||
cat turn-difference.txt | ||
rm -f turn-difference.txt | ||
rm -f ./standard | ||
rm -rf ./output | ||
exit 1 | ||
fi | ||
|
||
echo "identical. -- Test succeeded." | ||
rm -f turn-difference.txt | ||
done | ||
|
||
rm -f ./standard | ||
rm -rf ./output | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
curTurn=$(< ./turn) | ||
nextTurn=$((curTurn + 1)) | ||
|
||
if [[ ! -f ../../standard/standard ]]; then | ||
echo "Please build the standard executable before trying to create a new snapshot turn." | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -d turn_$nextTurn ]]; then | ||
mkdir turn_$nextTurn | ||
cp turn_$curTurn/game.out turn_$nextTurn/game.in | ||
cp turn_$curTurn/players.out turn_$nextTurn/players.in | ||
cp turn_$curTurn/template.3 turn_$nextTurn/orders.3 | ||
fi | ||
|
||
echo "Modify the input orders for turn_$nextTurn to test desired changes" | ||
echo "When that is complete, rerun this script." | ||
|
||
diff turn_$curTurn/template.3 turn_$nextTurn/orders.3 &> /dev/null | ||
if [[ $? = 0 ]]; | ||
then | ||
echo "No order changes have occured. Exiting." | ||
exit 0 | ||
fi | ||
|
||
echo "Running turn to produce new output" | ||
cd turn_$nextTurn | ||
../../../standard/standard run &> engine-output.txt | ||
|
||
if [[ $? != 0 ]]; then | ||
echo "Game engine crashed while generating turn. Turn not generated." | ||
cat engine-output.txt | ||
rm -f *.out | ||
rm -f template.* | ||
rm -f report.* | ||
rm -f times.* | ||
rm -f engine-output.txt | ||
fi | ||
|
||
echo "$nextTurn" > ../turn | ||
|
||
rm -f times.* |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Atlantis Engine Version: 5.2.5 (beta) | ||
Wyreth, Version: 2.0.0 (beta) | ||
|
||
Saved Game Engine Version: 5.2.4 (beta) | ||
Saved Rule-Set Version: 2.0.0 (beta) | ||
Reading the regions... | ||
Setting up the neighbors... | ||
Setting Up Turn... | ||
Reading the Gamemaster File... | ||
Reading the Orders File... | ||
QUITting Inactive Factions... | ||
Running the Turn... | ||
Running FIND Orders... | ||
Running ENTER/LEAVE Orders... | ||
Running PROMOTE/EVICT Orders... | ||
Running Combat... | ||
Running STEAL/ASSASSINATE Orders... | ||
Running GIVE Orders... | ||
Running ENTER NEW Orders... | ||
Running EXCHANGE Orders... | ||
Running DESTROY Orders... | ||
Running PILLAGE Orders... | ||
Running TAX Orders... | ||
Running GUARD 1 Orders... | ||
Running Magic Orders... | ||
Running SELL Orders... | ||
Running BUY Orders... | ||
Running FORGET Orders... | ||
Mid-Turn Processing... | ||
Running QUIT Orders... | ||
Removing Empty Units... | ||
Running WITHDRAW Orders... | ||
Running Consolidated Movement Orders... | ||
Running Teach Orders... | ||
Running Month-long Orders... | ||
Running Economics... | ||
Running Teleport Orders... | ||
Assessing Maintenance costs... | ||
Post-Turn Processing... | ||
Writing the Report File... | ||
... | ||
Writing order templates... | ||
... | ||
Writing Playerinfo File... | ||
Removing Dead Factions... | ||
done |
File renamed without changes.
Oops, something went wrong.