PocketMine-MP/tests/travis.sh
Dylan K. Taylor 4a4c28cd8c travis.sh: ditch PHP_BINARY variable, use PATH prefix instead
this is how normal people do it ...
2020-02-03 09:30:43 +00:00

55 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
PM_WORKERS="auto"
while getopts "t:" OPTION 2> /dev/null; do
case ${OPTION} in
t)
PM_WORKERS="$OPTARG"
;;
esac
done
#Run-the-server tests
DATA_DIR="test_data"
PLUGINS_DIR="$DATA_DIR/plugins"
rm -rf "$DATA_DIR"
rm PocketMine-MP.phar 2> /dev/null
cd tests/plugins/PocketMine-DevTools
php -dphar.readonly=0 ./src/DevTools/ConsoleScript.php --make ./ --relative ./ --out ../../../DevTools.phar
cd ../../..
php -dphar.readonly=0 ./build/server-phar.php ./PocketMine-MP.phar
if [ -f PocketMine-MP.phar ]; then
echo Server phar created successfully.
else
echo Server phar was not created!
exit 1
fi
mkdir "$DATA_DIR"
mkdir "$PLUGINS_DIR"
mv DevTools.phar "$PLUGINS_DIR"
cp -r tests/plugins/TesterPlugin "$PLUGINS_DIR"
echo -e "stop\n" | php PocketMine-MP.phar --no-wizard --disable-ansi --disable-readline --debug.level=2 --data="$DATA_DIR" --plugins="$PLUGINS_DIR" --anonymous-statistics.enabled=0 --settings.async-workers="$PM_WORKERS" --settings.enable-dev-builds=1
output=$(grep '\[TesterPlugin\]' "$DATA_DIR/server.log")
if [ "$output" == "" ]; then
echo TesterPlugin failed to run tests, check the logs
exit 1
fi
result=$(echo "$output" | grep 'Finished' | grep -v 'PASS')
if [ "$result" != "" ]; then
echo "$result"
echo Some tests did not complete successfully, changing build status to failed
exit 1
elif [ $(grep -c "ERROR\|CRITICAL\|EMERGENCY" "$DATA_DIR/server.log") -ne 0 ]; then
echo Server log contains error messages, changing build status to failed
exit 1
else
echo All tests passed
fi