From 5e57ad4d44306050f7a0641f2bc6625fd10115ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 21 Jun 2022 13:45:13 +0200 Subject: [PATCH] Added simple wrapper script to run PHPUnit tests for you. To use this, you need to set at least 4 variables in your ~/.bashrc (recommended): export FRIENDICA_MYSQL_HOST="localhost" export FRIENDICA_MYSQL_DATABASE="friendica_test" export FRIENDICA_MYSQL_USER="friendica_test" export FRIENDICA_MYSQL_PASSWWORD="friendica_test" Then you can put ./bin/dev/run_tests.sh into your .git/hooks/pre-commit file --- bin/dev/run_tests.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 bin/dev/run_tests.sh diff --git a/bin/dev/run_tests.sh b/bin/dev/run_tests.sh new file mode 100755 index 0000000000..d36b8bac02 --- /dev/null +++ b/bin/dev/run_tests.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +PHPUNIT_BIN="./vendor/bin/phpunit" + +if [ -z "${FRIENDICA_MYSQL_HOST}" -o -z "${FRIENDICA_MYSQL_DATABASE}" -o -z "${FRIENDICA_MYSQL_USER}" ] +then + echo "$0: Please add this to your ~/.bashrc file: + +export FRIENDICA_MYSQL_HOST=\"localhost\" +export FRIENDICA_MYSQL_DATABASE=\"friendica_test\" +export FRIENDICA_MYSQL_USER=\"friendica_test\" +export FRIENDICA_MYSQL_PASSWWORD=\"friendica_test\" +# Optional: +#export FRIENDICA_MYSQL_PORT=\"\" +#export FRIENDICA_MYSQL_SOCKET=\"\" + +And create the user/password and database (schema). This script will map then all variables for you and call phpunit properly." + exit 255 +elif [ ! -e "${PHPUNIT_BIN}" ] +then + echo "$0: Cannot find '${PHPUNIT_BIN}' executable." + exit 255 +fi + +export MYSQL_HOST="${FRIENDICA_MYSQL_HOST}" +export MYSQL_DATABASE="${FRIENDICA_MYSQL_DATABASE}" +export MYSQL_USER="${FRIENDICA_MYSQL_USER}" +export MYSQL_PASSWORD="${FRIENDICA_MYSQL_PASSWORD}" +export MYSQL_PORT="${FRIENDICA_MYSQL_PORT}" +export MYSQL_SOCKET="${FRIENDICA_MYSQL_SOCKET}" + +echo "$0: Running unit tests ..." +${PHPUNIT_BIN} -v tests/ > /tmp/friendica-phpunit.log 2>/dev/null +STATUS=$? +echo "$0: Returned status: ${STATUS}" +exit ${STATUS}