1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2025-01-09 13:42:38 +01:00
bygfoot/test/test-country-defs.sh
Tom Stellard 013df8dd93 Add json interface
This adds an initial version of a json interface to bygfoot.  This
is still in development so the interface may change in the future.  This
interface can be used for writing tests or for communication between a
client and server.

To use the interface, you can pass a json file with commands to bygfoot
using the --json option.
2021-03-05 23:38:28 -05:00

87 lines
1.3 KiB
Bash

bygfoot_bin=$1
bygfoot_bindir=`dirname $bygfoot_bin`
status=0
countries=" \
albania \
andorra \
armenia \
austria \
azerbaijan \
belarus \
belgium \
bosnia_herzegovina \
bulgaria \
croatia \
cyprus \
czech \
denmark \
england \
estonia \
faroe_islands \
finland \
france \
n_macedonia \
georgia \
germany \
gibraltar \
greece \
hungary \
iceland \
ireland \
israel \
italy \
kazakhstan \
kosovo \
latvia \
liechtenstein \
lithuania \
luxembourg \
malta \
moldova \
montenegro \
n_ireland \
netherlands \
norway \
poland \
portugal \
romania \
russia \
san_marino \
scotland \
serbia \
slovakia \
slovenia \
spain \
sweden \
switzerland \
turkey \
ukraine \
wales"
json_file=`mktemp`
pushd $bygfoot_bindir
for c in $countries; do
cat <<EOF > $json_file
{ 'commands' : [
{ 'add_country' : { 'name' : '$c' }},
{ 'start_bygfoot' : { }},
{ 'simulate_games' : {'seasons' : 2 }},
]}
EOF
tmphome=`mktemp -d`
if HOME=$tmphome ./bygfoot --random-seed=1 --json=$json_file; then
echo "$c: PASS"
else
echo "$c: FAIL"
status=1
fi
done
exit $status