diff --git a/.gitignore b/.gitignore index 1c5624fa2..e634e5c1d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ lib/plugins/sfDoctrinePlugin/test/functional/fixtures/log/ /vendor /composer.lock +/var diff --git a/docker-compose.yml b/docker-compose.yml index 326393e41..97607778e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -50,6 +50,7 @@ services: php81: <<: *services_php74 build: + context: .docker args: PHP_VERSION: '8.1' MEMCACHE_VERSION: '8.0' @@ -58,6 +59,7 @@ services: php82: <<: *services_php74 build: + context: .docker args: PHP_VERSION: '8.2' MEMCACHE_VERSION: '8.0' @@ -66,6 +68,7 @@ services: php83: <<: *services_php74 build: + context: .docker args: PHP_VERSION: '8.3' MEMCACHE_VERSION: '8.0' diff --git a/test/bin/test b/test/bin/test index 5305c0541..ae82e39df 100755 --- a/test/bin/test +++ b/test/bin/test @@ -9,81 +9,118 @@ # Example: "lowest highest" # -# Configuration -# -dependencyPreferences='highest' -skipPHPVersions='php8' +main () +{ + # Configuration + # + dependencyPreferences='highest' -# Commands -# -dcexec="docker-compose exec -u `id -u`:`id -g`" -installSubmodule='git submodule update --checkout --recursive --force' -composerUpdate='composer update --prefer-dist --no-suggest --optimize-autoloader' -symfonyTestSuite='data/bin/symfony symfony:test --trace' + # Commands + # + dcexec="docker-compose exec -u `id -u`:`id -g`" + installSubmodule='git submodule update --checkout --recursive --force' + composerUpdate='composer update --prefer-dist --no-suggest --optimize-autoloader' + symfonyTestSuite='data/bin/symfony symfony:test --trace' -# Parse arguments -# -phpVersions="${1-}" -dependencyPreferences="${2-${dependencyPreferences}}" -phpTestRuntime="${3-${symfonyTestSuite}}" + # Parse arguments + # + phpVersions="${1-}" + dependencyPreferences="${2-${dependencyPreferences}}" + phpTestRuntime="${3-${symfonyTestSuite}}" + + echo '+ docker-compose build' + docker-compose up -d --build --remove-orphans > /dev/null + + test x"" != x"${phpVersions}" || { + phpVersions=`fetchAllPHPVersions` + } + + tearDownRegisterFunction reset_submodules + + scriptAll +} script () { - echo - echo - echo $0 ${1} ${2} - echo - ${dcexec} ${1} php data/bin/check_configuration.php - ${dcexec} ${1} php ${phpTestRuntime} + echo + echo + echo $0 ${1} ${2} + echo + clearCacheOfMemcached + ${dcexec} ${1} php data/bin/check_configuration.php + ${dcexec} ${1} php ${phpTestRuntime} } scriptAll () { - for dependencyPreference in ${dependencyPreferences} - do - install_${dependencyPreference} - - for phpVersion in ${phpVersions} + for dependencyPreference in ${dependencyPreferences} do - script ${phpVersion} ${dependencyPreference} + install_${dependencyPreference} + + for phpVersion in ${phpVersions} + do + script ${phpVersion} ${dependencyPreference} + done done - done } fetchAllPHPVersions () { - docker-compose 2>/dev/null ps --services --filter status=running \ - | grep php \ - | sort \ - | grep -v ${skipPHPVersions} + docker-compose 2>/dev/null ps --services --filter status=running \ + | grep php \ + | sort } install_highest () { - ${installSubmodule} --remote - ${dcexec} composer ${composerUpdate} + ${installSubmodule} --remote + ${dcexec} composer ${composerUpdate} } install_lowest () { - reset_submodules + reset_submodules - ${installSubmodule} - ${dcexec} composer ${composerUpdate} --prefer-lowest + ${installSubmodule} + ${dcexec} composer ${composerUpdate} --prefer-lowest } reset_submodules () { - git submodule deinit --force --quiet -- . + git submodule deinit --force --quiet -- . - git submodule init + git submodule init } -echo '+ docker-compose build' -docker-compose up -d --build --remove-orphans > /dev/null +clearCacheOfMemcached () +{ + echo 'Clearing cache of memcached' + ${dcexec} memcached sh -c 'echo 'flush_all' | nc localhost 11211' +} + +tearDownRegisterFunction() +{ + test x"" != x"${tearDown_functions-}" || { + trap 'tearDown' 2 # CTRL-C + trap 'tearDown' QUIT TERM EXIT INT KILL SEGV + } + + case ${tearDown_functions-} in #( + ?*) tearDown_functions="${tearDown_functions} $1" ;; #( + *) tearDown_functions=$1 ;; + esac +} + +tearDown() +{ + test x"" != x"${tearDown_functions-}" || { + return 0 + } -test x"" != x"${phpVersions}" || { - phpVersions=`fetchAllPHPVersions` + for tearDown_function in ${tearDown_functions} + do + ${tearDown_function} + done } -scriptAll +main ${1+"$@"}