From 1a69f4e4c7b0b877b1a9230cdcf885d9d75b33a4 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 22 Sep 2022 14:53:56 +0200 Subject: [PATCH] Re-organize testrunners to use the same script(s). --- .github/workflows/ci.yml | 6 +--- docker-compose.yml | 2 +- run-tests-for-all-php-versions.sh | 46 +++++++++++++++++++++++++++++++ run-tests.sh | 13 +++++++++ run_tests_for_all_php_versions.sh | 11 -------- 5 files changed, 61 insertions(+), 17 deletions(-) create mode 100755 run-tests-for-all-php-versions.sh create mode 100755 run-tests.sh delete mode 100755 run_tests_for_all_php_versions.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b24dc29..079071cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,9 +65,5 @@ jobs: restore-keys: | Smartyv3-${{ runner.os }}-php-${{ matrix.php-version }}- - - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer install --prefer-dist --no-progress --no-suggest - - name: Run tests with phpunit - run: ./phpunit.sh + run: ./run-tests.sh diff --git a/docker-compose.yml b/docker-compose.yml index 5dedb729..3217ed91 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: volumes: - .:/app working_dir: /app - entrypoint: sh ./utilities/testrunners/run-test.sh + entrypoint: sh ./run-tests.sh php54: extends: service: base diff --git a/run-tests-for-all-php-versions.sh b/run-tests-for-all-php-versions.sh new file mode 100755 index 00000000..196f0dba --- /dev/null +++ b/run-tests-for-all-php-versions.sh @@ -0,0 +1,46 @@ +#!/bin/bash +Help() +{ + # Display Help + echo "Runs PHPUnit tests for all PHP versions supported by this version of Smarty." + echo + echo "Syntax: $0 [-e|h]" + echo "options:" + echo "e Exclude a group of unit tests, e.g. -e 'slow'" + echo "h Print this Help." + echo +} + +Exclude="" + +# Get the options +while getopts ":he:" option; do + case $option in + e) # Exclude + echo $OPTARG + Exclude=$OPTARG;; + h) # display Help + Help + exit;; + \?) # Invalid option + echo "Error: Invalid option" + exit;; + esac +done + +if [ -z $Exclude ]; +then + Entrypoint="./run-tests.sh" +else + Entrypoint="./run-tests.sh $Exclude" +fi + +# Runs tests for all supported PHP versions +docker-compose run --entrypoint "$Entrypoint" php54 && \ +docker-compose run --entrypoint "$Entrypoint" php55 && \ +docker-compose run --entrypoint "$Entrypoint" php56 && \ +docker-compose run --entrypoint "$Entrypoint" php70 && \ +docker-compose run --entrypoint "$Entrypoint" php71 && \ +docker-compose run --entrypoint "$Entrypoint" php72 && \ +docker-compose run --entrypoint "$Entrypoint" php73 && \ +docker-compose run --entrypoint "$Entrypoint" php74 diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 00000000..eac36dea --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,13 @@ +#!/bin/sh +composer update + +php -r 'echo "\nPHP version " . phpversion() . ". ";'; + +if [ -z $1 ]; +then + echo "Running all unit tests.\n" + php ./vendor/phpunit/phpunit/phpunit tests +else + echo "Running all unit tests, except tests marked with @group $1.\n" + php ./vendor/phpunit/phpunit/phpunit --exclude-group $1 tests +fi \ No newline at end of file diff --git a/run_tests_for_all_php_versions.sh b/run_tests_for_all_php_versions.sh deleted file mode 100755 index 67e3c6de..00000000 --- a/run_tests_for_all_php_versions.sh +++ /dev/null @@ -1,11 +0,0 @@ -# Runs tests for all supported PHP versions >= PHP 5.4. -# Cannot get 5.2 and 5.3 to run in docker anymore - -docker-compose run php54 && \ -docker-compose run php55 && \ -docker-compose run php56 && \ -docker-compose run php70 && \ -docker-compose run php71 && \ -docker-compose run php72 && \ -docker-compose run php73 && \ -docker-compose run php74 \ No newline at end of file