Skip to content

Commit

Permalink
feat(test): start service of only targeted php versions
Browse files Browse the repository at this point in the history
  • Loading branch information
alquerci committed Apr 8, 2024
1 parent 6959559 commit b620436
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions tests/bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
__DIR__=`dirname "$0"`
ROOT_DIR="${__DIR__}/../.."

PHP_VERSIONS_SUPPORTED_PATTERN='(php74|php8)'

main ()
{
importEnvironmentVariablesFromDirectory "${ROOT_DIR}"
Expand All @@ -11,8 +13,6 @@ main ()

startDockerComposeServices

populatePHPVersions

runTests
}

Expand All @@ -28,7 +28,7 @@ Usage:
Options:
--help Show this screen.
--php-versions Select specific php versions. [default: ${PHP_VERSIONS}]
--php-versions Select specific php versions. [default: '`echo ${PHP_VERSIONS}`']
Examples:
php53
'php53 php54'
Expand Down Expand Up @@ -86,7 +86,7 @@ importEnvironmentVariablesFromDirectory ()
startDockerComposeServices ()
{
echo "+ ${DOCKER_COMPOSE} build"
${DOCKER_COMPOSE} up -d --build --remove-orphans > /dev/null
${DOCKER_COMPOSE} up -d --build --remove-orphans ${PHP_VERSIONS} > /dev/null
}

configureWithArguments ()
Expand All @@ -105,6 +105,8 @@ configureWithArguments ()
PHP_TEST_RUNTIME='tests/run.php'
hasHelpOption=false

populatePHPVersions

parseOperands ${1+"$@"}

if ${hasHelpOption}; then
Expand Down Expand Up @@ -141,13 +143,18 @@ hasTty ()
populatePHPVersions ()
{
if test x'all' = x"${PHP_VERSIONS}"; then
PHP_VERSIONS=`fetchAllPHPVersions`
PHP_VERSIONS=`fetchSupportedPHPVersions`
else :; fi
}

fetchSupportedPHPVersions ()
{
fetchAllPHPVersions | grep -E "${PHP_VERSIONS_SUPPORTED_PATTERN}"
}

fetchAllPHPVersions ()
{
${DOCKER_COMPOSE} 2>/dev/null ps --services --filter status=running \
${DOCKER_COMPOSE} 2>/dev/null ps --services \
| grep php \
| sort
}
Expand Down

0 comments on commit b620436

Please sign in to comment.