summaryrefslogtreecommitdiff
path: root/bin/ai/regression/run.sh
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2014-09-21 16:41:03 +0000
committerfonsinchen <fonsinchen@openttd.org>2014-09-21 16:41:03 +0000
commitd92c95b29c6ae7b03c76852eec68fc0d425884cb (patch)
tree4ee219926a9cee1407ccc08a8890078b87a5c0cd /bin/ai/regression/run.sh
parent1a5b2f0e17c5e694401e4d3730ed348e9f6d5f76 (diff)
downloadopenttd-d92c95b29c6ae7b03c76852eec68fc0d425884cb.tar.xz
(svn r26895) -Change: Allow for multiple independent test cases for AI API regression
Diffstat (limited to 'bin/ai/regression/run.sh')
-rwxr-xr-xbin/ai/regression/run.sh43
1 files changed, 33 insertions, 10 deletions
diff --git a/bin/ai/regression/run.sh b/bin/ai/regression/run.sh
index 3420742e9..adf4dba0c 100755
--- a/bin/ai/regression/run.sh
+++ b/bin/ai/regression/run.sh
@@ -2,14 +2,11 @@
# $Id$
-if ! [ -f ai/regression/regression.nut ]; then
+if ! [ -f ai/regression/run.sh ]; then
echo "Make sure you are in the root of OpenTTD before starting this script."
exit 1
fi
-cp ai/regression/regression.nut ai/regression/main.nut
-cp ai/regression/regression_info.nut ai/regression/info.nut
-
if [ -f scripts/game_start.scr ]; then
mv scripts/game_start.scr scripts/game_start.scr.regression
fi
@@ -22,15 +19,43 @@ fi
if [ "$1" = "-g" ]; then
gdb="gdb --ex run --args "
fi
-if [ -n "$gdb" ]; then
- $gdb ./openttd -x -c ai/regression/regression.cfg $params -g ai/regression/regression.sav
+
+if [ -d "ai/regression/tst_$1" ]; then
+ tests="ai/regression/tst_$1"
+elif [ -d "ai/regression/tst_$2" ]; then
+ tests="ai/regression/tst_$2"
else
- ./openttd -x -c ai/regression/regression.cfg $params -g ai/regression/regression.sav -d script=2 -d misc=9 2>&1 | awk '{ gsub("0x(\\(nil\\)|0+)(x0)?", "0x00000000", $0); gsub("^dbg: \\[script\\]", "", $0); gsub("^ ", "ERROR: ", $0); gsub("ERROR: \\[1\\] ", "", $0); gsub("\\[P\\] ", "", $0); print $0; }' | grep -v '^dbg: \[.*\]' > tmp.regression
+ tests=ai/regression/tst_*
fi
ret=0
+for tst in $tests; do
+ echo "running $tst"
+
+ # Make sure that only one info.nut is present for each test run. Otherwise openttd gets confused.
+ cp ai/regression/regression_info.nut $tst/info.nut
+
+ sav=$tst/test.sav
+ if ! [ -f $sav ]; then
+ sav=ai/regression/empty.sav
+ fi
+
+ if [ -n "$gdb" ]; then
+ $gdb ./openttd -x -c ai/regression/regression.cfg $params -g $sav
+ else
+ ./openttd -x -c ai/regression/regression.cfg $params -g $sav -d script=2 -d misc=9 2>&1 | awk '{ gsub("0x(\\(nil\\)|0+)(x0)?", "0x00000000", $0); gsub("^dbg: \\[script\\]", "", $0); gsub("^ ", "ERROR: ", $0); gsub("ERROR: \\[1\\] ", "", $0); gsub("\\[P\\] ", "", $0); print $0; }' | grep -v '^dbg: \[.*\]' > tmp.regression
+ fi
+
+ if [ -z "$gdb" ]; then
+ # Ugly newline insertion, but it says /bin/sh above ...
+ res="$res
+`diff -ub $tst/result.txt tmp.regression`"
+ fi
+
+ rm $tst/info.nut
+done
+
if [ -z "$gdb" ]; then
- res="`diff -ub ai/regression/regression.txt tmp.regression`"
if [ -z "$res" ]; then
echo "Regression test passed!"
else
@@ -42,8 +67,6 @@ if [ -z "$gdb" ]; then
echo "Regression test done"
fi
-rm -f ai/regression/main.nut ai/regression/info.nut
-
if [ -f scripts/game_start.scr.regression ]; then
mv scripts/game_start.scr.regression scripts/game_start.scr
fi