Emmanuel BENOîT
cb2553d1e5
* Added tests of the command line tools to the post-build scripts * Local deployment documentation mentions ImportResources
58 lines
1.5 KiB
Bash
58 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
cd legacyworlds-server-data/db-structure
|
|
if ! [ -f db-config.txt ]; then
|
|
cat > db-config.txt <<EOF
|
|
admin=$USER
|
|
db=tests
|
|
user=tests
|
|
password=tests
|
|
EOF
|
|
fi
|
|
export TEST_DATABASE="`grep ^db= db-config.txt | sed -e s/.*=//`"
|
|
export TEST_USER="`grep ^user= db-config.txt | sed -e s/.*=//`"
|
|
|
|
echo
|
|
echo
|
|
echo "======================================================================"
|
|
echo "LOADING DATABASE DEFINITION ..."
|
|
echo "======================================================================"
|
|
echo
|
|
echo
|
|
psql -vQUIET=1 -vON_ERROR_STOP=1 -e --file database.sql || exit 1
|
|
|
|
if ! [ -d tests/admin ] && ! [ -d tests/user ]; then
|
|
echo
|
|
echo
|
|
echo "WARNING: no unit tests to run"
|
|
echo
|
|
echo
|
|
exit 0
|
|
fi
|
|
|
|
echo
|
|
echo
|
|
echo "======================================================================"
|
|
echo "LOADING TEST FRAMEWORK ..."
|
|
echo "======================================================================"
|
|
echo
|
|
echo
|
|
psql -vQUIET=1 -f tests/pgtap.sql $TEST_DATABASE || exit 1
|
|
|
|
echo
|
|
echo
|
|
echo "======================================================================"
|
|
echo "RUNNING DATABASE TESTS ..."
|
|
echo "======================================================================"
|
|
echo
|
|
echo
|
|
cd tests
|
|
if [ -d admin ]; then
|
|
pg_prove -d $TEST_DATABASE `find admin/ -type f -name '*.sql'` || exit 1
|
|
fi
|
|
if [ -d user ]; then
|
|
pg_prove -U $TEST_USER -d $TEST_DATABASE `find user/ -type f -name '*.sql'` || exit 1
|
|
fi
|
|
if [ -x dirty/run-dirty-tests.sh ]; then
|
|
( cd dirty; exec ./run-dirty-tests.sh ) || exit 1
|
|
fi
|