add missing .sh files to git (previously blocked by .gitignore)

add an integration test for run-turn.lua
This commit is contained in:
Enno Rehling 2015-09-07 15:27:30 +02:00
parent b6ba42c3de
commit bf86b1d66a
9 changed files with 136 additions and 1 deletions

1
.gitignore vendored
View File

@ -19,7 +19,6 @@ ipch/
*.opensdf
*.pdb
*.sdf
*.sh
*.suo
*.user

24
process/compress.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
if [ -z $ERESSEA ]; then
echo "You need to define the \$ERESSEA environment variable to run $0"
exit -2
fi
GAME=$ERESSEA/game-$1
GAME_NAME=$(grep name $GAME/eressea.ini | sed 's/.*=\s*//')
TURN=$2
if [ -z $TURN ]
then
TURN=`cat $GAME/turn`
fi
if [ ! -d $GAME/reports ]; then
echo "cannot find reprts directory in $GAME"
exit
fi
cd $GAME/reports
compress.py $TURN "$GAME_NAME"
cd -

10
process/functions.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash
PATH=$ERESSEA/bin:$PATH
function abort() {
if [ $# -gt 0 ]; then
echo $@
fi
exit -1
}

1
process/received-mail.sh Normal file
View File

@ -0,0 +1 @@
ls -1 orders.dir/turn* | sed -e 's/.*turn-\(.*\),gruenbaer.*/\1/' | sort -u

1
process/received.sh Normal file
View File

@ -0,0 +1 @@
grep -hiw ERESSEA orders.dir/turn-* | cut -d\ -f2 | sort -u

22
process/run-turn.sh Executable file
View File

@ -0,0 +1,22 @@
GAME=$1
TURN=$2
if [ ! -d $ERESSEA/game-$GAME ] ; then
echo "No such game: $GAME"
exit 1
fi
cd $ERESSEA/game-$GAME
if [ -z $TURN ]; then
TURN=$(cat turn)
fi
echo "running turn $TURN, game $GAME"
if [ -d orders.dir.$TURN ]; then
echo "orders.dir.$TURN already exists"
else
mv orders.dir orders.dir.$TURN
mkdir -p orders.dir
fi
ls -1rt orders.dir.$TURN/turn-* | xargs cat > orders.$TURN
$ERESSEA/bin/eressea -t $TURN run-turn.lua

33
process/sendreports.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
##
## Prepare the report
if [ -z $ERESSEA ]; then
echo "You have to define the \$ERESSEA environment variable to run $0"
exit -2
fi
source $HOME/bin/functions.sh
source $ERESSEA/etc/eressea.conf
if [ ! -z $1 ]; then
GAME=$ERESSEA/game-$1
else
GAME=$ERESSEA
fi
cd $GAME/reports || abort "could not chdir to reports directory"
for REPORT in *.sh
do
echo -n "Sending "
basename $REPORT .sh
bash $REPORT
done
cd -
if [ -e $GAME/ages.sh ]; then
cd $GAME
./ages.sh
cd -
fi

View File

@ -19,3 +19,4 @@ inifile
s/runtests
cd tests
./write-reports.sh
./run-turn.sh

44
tests/run-turn.sh Executable file
View File

@ -0,0 +1,44 @@
NEWFILES="data/185.dat datum parteien parteien.full passwd score turn"
cleanup () {
rm -rf reports $NEWFILES
}
setup() {
ln -sf ../scripts/config.lua
}
quit() {
test -n "$2" && echo $2
exit $1
}
ROOT=`pwd`
while [ ! -d $ROOT/.git ]; do
ROOT=`dirname $ROOT`
done
set -e
cd $ROOT/tests
setup
cleanup
VALGRIND=`which valgrind`
SERVER=../Debug/eressea/eressea
if [ -n "$VALGRIND" ]; then
SUPP=../share/ubuntu-12_04.supp
SERVER="$VALGRIND --suppressions=$SUPP --error-exitcode=1 --leak-check=no $SERVER"
fi
echo "running $SERVER"
$SERVER -t 184 ../scripts/run-turn.lua
[ -d reports ] || quit 4 "no reports directory created"
CRFILE=185-zvto.cr
for file in $NEWFILES reports/$CRFILE ; do
[ -e $file ] || quit 5 "did not create $file"
done
grep -q PARTEI reports/$CRFILE || quit 1 "CR did not contain any factions"
grep -q REGION reports/$CRFILE || quit 2 "CR did not contain any regions"
grep -q SCHIFF reports/$CRFILE || quit 3 "CR did not contain any ships"
grep -q BURG reports/$CRFILE || quit 4 "CR did not contain any buildings"
grep -q EINHEIT reports/$CRFILE || quit 5 "CR did not contain any units"
grep -q GEGENSTAENDE reports/$CRFILE || quit 6 "CR did not contain any items"
echo "integration tests: PASS"
cleanup