diff --git a/.gitignore b/.gitignore index 7173836cc..24a918963 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ ipch/ *.opensdf *.pdb *.sdf -*.sh *.suo *.user diff --git a/process/compress.sh b/process/compress.sh new file mode 100755 index 000000000..f012e68c8 --- /dev/null +++ b/process/compress.sh @@ -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 - diff --git a/process/functions.sh b/process/functions.sh new file mode 100644 index 000000000..859fd302a --- /dev/null +++ b/process/functions.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +PATH=$ERESSEA/bin:$PATH + +function abort() { + if [ $# -gt 0 ]; then + echo $@ + fi + exit -1 +} diff --git a/process/received-mail.sh b/process/received-mail.sh new file mode 100644 index 000000000..b6b4a0605 --- /dev/null +++ b/process/received-mail.sh @@ -0,0 +1 @@ +ls -1 orders.dir/turn* | sed -e 's/.*turn-\(.*\),gruenbaer.*/\1/' | sort -u diff --git a/process/received.sh b/process/received.sh new file mode 100644 index 000000000..817186000 --- /dev/null +++ b/process/received.sh @@ -0,0 +1 @@ +grep -hiw ERESSEA orders.dir/turn-* | cut -d\ -f2 | sort -u diff --git a/process/run-turn.sh b/process/run-turn.sh new file mode 100755 index 000000000..9cc4e4ffd --- /dev/null +++ b/process/run-turn.sh @@ -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 diff --git a/process/sendreports.sh b/process/sendreports.sh new file mode 100755 index 000000000..fc24200b6 --- /dev/null +++ b/process/sendreports.sh @@ -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 + diff --git a/s/travis-build b/s/travis-build index a6c920340..414a70f80 100755 --- a/s/travis-build +++ b/s/travis-build @@ -19,3 +19,4 @@ inifile s/runtests cd tests ./write-reports.sh +./run-turn.sh diff --git a/tests/data/184.dat b/tests/data/184.dat index ffe368510..734e5a19f 100644 Binary files a/tests/data/184.dat and b/tests/data/184.dat differ diff --git a/tests/orders.184 b/tests/orders.184 index e69de29bb..87825c1fd 100644 --- a/tests/orders.184 +++ b/tests/orders.184 @@ -0,0 +1,4 @@ +ERESSEA 6rLo "4jLm82" +EINHEIT 7Lgf +NACH NW NW +NAECHSTER diff --git a/tests/run-turn.sh b/tests/run-turn.sh new file mode 100755 index 000000000..4055613e5 --- /dev/null +++ b/tests/run-turn.sh @@ -0,0 +1,56 @@ +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 +echo "integration tests: FAILED" +exit $1 +} + +assert_grep_count() { +file=$1 +expr=$2 +expect=$3 +count=`grep -cE $expr $file` +[ $count -eq $expect ] || quit 1 "expected $expect counts of $expr in $file, got $count" +} + +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 +assert_grep_count reports/$CRFILE '^REGION' 7 +assert_grep_count reports/$CRFILE '^PARTEI' 2 +assert_grep_count reports/$CRFILE '^SCHIFF' 1 +assert_grep_count reports/$CRFILE '^BURG' 1 +assert_grep_count reports/$CRFILE '^EINHEIT' 2 +assert_grep_count reports/$CRFILE '^GEGENSTAENDE' 2 + +assert_grep_count reports/185-6rLo.cr '^EINHEIT' 2 +assert_grep_count reports/185-6rLo.cr '^REGION' 13 +echo "integration tests: PASS" +cleanup