diff options
Diffstat (limited to 'autotest.sh')
-rwxr-xr-x | autotest.sh | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/autotest.sh b/autotest.sh index 7214df18b14..32a844a670d 100755 --- a/autotest.sh +++ b/autotest.sh @@ -1,16 +1,8 @@ #!/usr/bin/env bash # -# ownCloud -# -# @author Vincent Petry -# @author Morris Jobke -# @author Robin McCorkell -# @author Thomas Müller -# @author Andreas Fischer -# @author Joas Schilling -# @author Lukas Reschke -# @author Jörn Friedrich Dreyer -# @copyright 2012-2015 Thomas Müller thomas.mueller@tmit.eu +# SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-FileCopyrightText: 2012-2016 ownCloud, Inc. +# SPDX-License-Identifier: AGPL-3.0-only # DATABASENAME=oc_autotest @@ -29,7 +21,15 @@ if [ -z "$PHP_EXE" ]; then PHP_EXE=php fi PHP=$(which "$PHP_EXE") -PHPUNIT=$(which phpunit) +if [ -z "$PHPUNIT_EXE" ]; then + if [ -f lib/composer/bin/phpunit ]; then + PHPUNIT_EXE="./lib/composer/bin/phpunit" + PHPUNIT=$(readlink -f "$PHPUNIT_EXE") + else + PHPUNIT_EXE=phpunit + PHPUNIT=$(which "$PHPUNIT_EXE") + fi +fi set -e @@ -53,7 +53,8 @@ else fi if ! [ -x "$PHPUNIT" ]; then - echo "phpunit executable not found, please install phpunit version >= 6.5" >&2 + echo "phpunit executable not found, please install phpunit version >= 10.5 manually or via:" >&2 + echo " composer install" >&2 exit 3 fi @@ -68,8 +69,8 @@ PHPUNIT_VERSION=$($PHPUNIT --version | cut -d" " -f2) PHPUNIT_MAJOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f1) PHPUNIT_MINOR_VERSION=$(echo "$PHPUNIT_VERSION" | cut -d"." -f2) -if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 6 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 6 -a "$PHPUNIT_MINOR_VERSION" -ge 5 \) ]; then - echo "phpunit version >= 6.5 required. Version found: $PHPUNIT_VERSION" >&2 +if ! [ "$PHPUNIT_MAJOR_VERSION" -gt 10 -o \( "$PHPUNIT_MAJOR_VERSION" -eq 10 -a "$PHPUNIT_MINOR_VERSION" -ge 5 \) ]; then + echo "phpunit version >= 10.5 required. Version found: $PHPUNIT_VERSION" >&2 exit 4 fi @@ -145,6 +146,9 @@ function cleanup_config { fi # Remove mysqlmb4.config.php rm -f config/mysqlmb4.config.php + + # restore .htaccess + git restore .htaccess } # restore config on exit @@ -304,13 +308,15 @@ function execute_tests { if [ "$DB" == "pgsql" ] ; then if [ ! -z "$USEDOCKER" ] ; then echo "Fire up the postgres docker" - DOCKER_CONTAINER_ID=$(docker run -e POSTGRES_USER="$DATABASEUSER" -e POSTGRES_PASSWORD=owncloud -d postgres) + DOCKER_CONTAINER_ID=$(docker run -e POSTGRES_DB="$DATABASENAME" -e POSTGRES_USER="$DATABASEUSER" -e POSTGRES_PASSWORD=owncloud -d postgres) DATABASEHOST=$(docker inspect --format="{{.NetworkSettings.IPAddress}}" "$DOCKER_CONTAINER_ID") echo "Waiting for Postgres initialisation ..." - # grep exits on the first match and then the script continues - docker logs -f "$DOCKER_CONTAINER_ID" 2>&1 | grep -q "database system is ready to accept connections" + if ! apps/files_external/tests/env/wait-for-connection $DATABASEHOST 5432 60; then + echo "[ERROR] Waited 60 seconds for $DATABASEHOST, no response" >&2 + exit 1 + fi echo "Postgres is up." else @@ -390,8 +396,8 @@ function execute_tests { echo "No coverage" fi - echo "${PHPUNIT[@]}" --configuration phpunit-autotest.xml $GROUP $COVER --log-junit "autotest-results-$DB.xml" "$2" "$3" - "${PHPUNIT[@]}" --configuration phpunit-autotest.xml $GROUP $COVER --log-junit "autotest-results-$DB.xml" "$2" "$3" + echo "$PHPUNIT" --colors=always --configuration phpunit-autotest.xml $GROUP $COVER --log-junit "autotest-results-$DB.xml" "$2" "$3" + "$PHPUNIT" --colors=always --configuration phpunit-autotest.xml $GROUP $COVER --log-junit "autotest-results-$DB.xml" "$2" "$3" RESULT=$? if [ "$PRIMARY_STORAGE_CONFIG" == "swift" ] ; then |