(svn r26895) -Change: Allow for multiple independent test cases for AI API regression

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
fonsinchen 10 years ago
parent 1a5b2f0e17
commit d92c95b29c

@ -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/^+//'

@ -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"; }

@ -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

Loading…
Cancel
Save