Emmanuel BENOîT
c18bdc2d1f
* Added a system that allows "dirty" tests to be written. These tests actually need to change the database, so a temporary test database must be created to run them.
58 lines
1.5 KiB
Bash
Executable file
58 lines
1.5 KiB
Bash
Executable file
#!/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.sql ]; then
|
|
( cd dirty; exec ./run-dirty-tests.sql ) || exit 1
|
|
fi
|