summaryrefslogtreecommitdiff
path: root/bin/ai
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
parent1a5b2f0e17c5e694401e4d3730ed348e9f6d5f76 (diff)
downloadopenttd-d92c95b29c6ae7b03c76852eec68fc0d425884cb.tar.xz
(svn r26895) -Change: Allow for multiple independent test cases for AI API regression
Diffstat (limited to 'bin/ai')
-rwxr-xr-xbin/ai/regression/completeness.sh6
-rw-r--r--bin/ai/regression/empty.sav (renamed from bin/ai/regression/regression.sav)bin97731 -> 97731 bytes
-rw-r--r--bin/ai/regression/regression_info.nut2
-rwxr-xr-xbin/ai/regression/run.sh43
-rw-r--r--bin/ai/regression/tst_regression/main.nut (renamed from bin/ai/regression/regression.nut)0
-rw-r--r--bin/ai/regression/tst_regression/require.nut (renamed from bin/ai/regression/require.nut)0
-rw-r--r--bin/ai/regression/tst_regression/result.txt (renamed from bin/ai/regression/regression.txt)0
7 files changed, 37 insertions, 14 deletions
diff --git a/bin/ai/regression/completeness.sh b/bin/ai/regression/completeness.sh
index e2e4dccd8..9f5e96eb0 100755
--- a/bin/ai/regression/completeness.sh
+++ b/bin/ai/regression/completeness.sh
@@ -2,12 +2,12 @@
# $Id$
-if ! [ -f ai/regression/regression.nut ]; then
+if ! [ -f ai/regression/completeness.sh ]; then
echo "Make sure you are in the root of OpenTTD before starting this script."
exit 1
fi
-cat ai/regression/regression.nut | tr ';' '\n' | awk '
+cat ai/regression/tst_*/main.nut | tr ';' '\n' | awk '
/^function/ {
for (local in locals) {
delete locals[local]
@@ -61,7 +61,7 @@ cat ai/regression/regression.nut | tr ';' '\n' | awk '
}
' | sed 's/ //g' | sort | uniq > tmp.in_regression
-grep 'DefSQ.*Method' ../src/ai/api/*.hpp.sq | grep -v 'AIError::' | grep -v 'AIAbstractList::Valuate' | grep -v '::GetClassName' | sed 's/^[^,]*, &//g;s/,[^,]*//g' | sort > tmp.in_api
+grep 'DefSQ.*Method' ../src/script/api/ai/*.hpp.sq | grep -v 'AIError::' | grep -v 'AIAbstractList::Valuate' | grep -v '::GetClassName' | sed 's/^[^,]*, &//g;s/,[^,]*//g' | sort > tmp.in_api
diff -u tmp.in_regression tmp.in_api | grep -v '^+++' | grep '^+' | sed 's/^+//'
diff --git a/bin/ai/regression/regression.sav b/bin/ai/regression/empty.sav
index cf97052c2..cf97052c2 100644
--- a/bin/ai/regression/regression.sav
+++ b/bin/ai/regression/empty.sav
Binary files differ
diff --git a/bin/ai/regression/regression_info.nut b/bin/ai/regression/regression_info.nut
index 6eb19140d..86f4484fe 100644
--- a/bin/ai/regression/regression_info.nut
+++ b/bin/ai/regression/regression_info.nut
@@ -4,7 +4,7 @@ class Regression extends AIInfo {
function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
function GetName() { return "Regression"; }
function GetShortName() { return "REGR"; }
- function GetDescription() { return "This runs regression-tests on all commands. On the same map the result should always be the same."; }
+ function GetDescription() { return "This runs regression-tests on some commands. On the same map the result should always be the same."; }
function GetVersion() { return 1; }
function GetAPIVersion() { return "1.5"; }
function GetDate() { return "2007-03-18"; }
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
diff --git a/bin/ai/regression/regression.nut b/bin/ai/regression/tst_regression/main.nut
index d856c3307..d856c3307 100644
--- a/bin/ai/regression/regression.nut
+++ b/bin/ai/regression/tst_regression/main.nut
diff --git a/bin/ai/regression/require.nut b/bin/ai/regression/tst_regression/require.nut
index 360e1c23b..360e1c23b 100644
--- a/bin/ai/regression/require.nut
+++ b/bin/ai/regression/tst_regression/require.nut
diff --git a/bin/ai/regression/regression.txt b/bin/ai/regression/tst_regression/result.txt
index 5150c5c28..5150c5c28 100644
--- a/bin/ai/regression/regression.txt
+++ b/bin/ai/regression/tst_regression/result.txt