Skip to content
Snippets Groups Projects
Commit d07e519a authored by Fran Garcia-Linares's avatar Fran Garcia-Linares
Browse files

Issue #3444792 by fjgarlin, mondrake, Berdir, mark_fullmer, VladimirAus: Prepare for PHPUnit 10

parent 4d1f33d5
Branches
Tags 1.3.12
1 merge request!198New phpunit10 options.
Pipeline #174259 passed
# GitLab Templates Changelog
## 1.3.12 - 2024-05-xx
## 1.3.12 - 2024-05-16
#3444792 - Prepare for PHPUnit 10.\
#3447105 - DB requirements for next major were raised.\
#3343522 - Hide variables that should not be overridden.\
#3444601 - Make $DRUPAL_CORE and $PHP_VERSION available in all jobs.\
#3444921 - Run all jobs in 'Check Code', do not halt at first failure.\
#3439644 - Review all documentation pages, part 2.\
#3444778 - Improve the check-versions job output.
......
......@@ -98,3 +98,9 @@ phpunit:
variables:
SYMFONY_DEPRECATIONS_HELPER: "ignoreFile=./.local-deprecation-ignore.txt"
```
Finally, and if you are using a Drupal core version that comes with PHPUnit 10 or above (this would be Drupal 11 or above), you can also set the flag `--fail-on-deprecation` in the `_PHPUNIT_EXTRA` variable. This is only needed if you are running the tests in non-concurrent mode (see above). The code would look like this:
```
variables:
_PHPUNIT_EXTRA: '--fail-on-deprecation'
```
......@@ -855,8 +855,13 @@ nightwatch (next major):
# Otherwise add --group $_PHPUNIT_TESTGROUPS
WHAT_TO_RUN=$([[ "$_PHPUNIT_TESTGROUPS" == "" || "$_PHPUNIT_TESTGROUPS" == "--all" ]] && echo "" || echo "--group $_PHPUNIT_TESTGROUPS")
echo "_PHPUNIT_CONCURRENT=$_PHPUNIT_CONCURRENT, _PHPUNIT_TESTGROUPS=$_PHPUNIT_TESTGROUPS, _PHPUNIT_EXTRA=$_PHPUNIT_EXTRA WHAT_TO_RUN=$WHAT_TO_RUN"
echo "executing: sudo -u www-data -E vendor/bin/phpunit --no-interaction --printer='\Drupal\Tests\Listeners\HtmlOutputPrinter' --bootstrap $PWD/$_WEB_ROOT/core/tests/bootstrap.php $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME --log-junit $CI_PROJECT_DIR/junit.xml $WHAT_TO_RUN $_PHPUNIT_EXTRA"
sudo -u www-data -E vendor/bin/phpunit --no-interaction --printer="\Drupal\Tests\Listeners\HtmlOutputPrinter" --bootstrap $PWD/$_WEB_ROOT/core/tests/bootstrap.php $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME --log-junit $CI_PROJECT_DIR/junit.xml $WHAT_TO_RUN $_PHPUNIT_EXTRA || EXIT_CODE=$?
PHPUNIT_VERSION=$(vendor/bin/phpunit --version | awk -F'[ .]' "{print \$2}")
PHPUNIT_OPTIONS=''
if [ "$PHPUNIT_VERSION" == "9" ]; then
PHPUNIT_OPTIONS="--printer=\Drupal\Tests\Listeners\HtmlOutputPrinter"
fi
echo "executing: sudo -u www-data -E vendor/bin/phpunit $PHPUNIT_OPTIONS --bootstrap $PWD/$_WEB_ROOT/core/tests/bootstrap.php $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME --log-junit $CI_PROJECT_DIR/junit.xml $WHAT_TO_RUN $_PHPUNIT_EXTRA"
sudo -u www-data -E vendor/bin/phpunit $PHPUNIT_OPTIONS --bootstrap $PWD/$_WEB_ROOT/core/tests/bootstrap.php $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME --log-junit $CI_PROJECT_DIR/junit.xml $WHAT_TO_RUN $_PHPUNIT_EXTRA || EXIT_CODE=$?
elif [ "$_PHPUNIT_CONCURRENT" == "1" ]; then
# if _PHPUNIT_TESTGROUPS is blank then do not add anything, because the test group will be handled by the matrix.
# if _PHPUNIT_TESTGROUPS is --all then add --directory modules/custom/$CI_PROJECT_NAME
......
......@@ -32,14 +32,20 @@ fi
printf "$DIVIDER\nAfter reverting all non-test changes, the remaining changed files are:\n"
git diff ${BASELINE} --stat=120,110
PHPUNIT_VERSION=$(vendor/bin/phpunit --version | awk -F'[ .]' "{print \$2}")
PHPUNIT_OPTIONS=''
if [ "$PHPUNIT_VERSION" == "9" ]; then
PHPUNIT_OPTIONS="--printer=\Drupal\Tests\Listeners\HtmlOutputPrinter"
fi
TESTS_CHANGED=$(git diff ${BASELINE} --name-only | grep -E 'Test\.php$') || true
if [ "$TESTS_CHANGED" != "" ]; then
printf " \n2️⃣ Running tests changed in this merge request\n \nThe following test files have been changed, and only these tests will be run:\n$TESTS_CHANGED\n "
for file in $TESTS_CHANGED; do
test=$CI_PROJECT_DIR/$_WEB_ROOT/modules/custom/$CI_PROJECT_NAME/$file
if [ "$_PHPUNIT_CONCURRENT" == "0" ]; then
printf "$DIVIDER\n_PHPUNIT_CONCURRENT=$_PHPUNIT_CONCURRENT, executing: sudo -u www-data -E vendor/bin/phpunit --no-interaction --printer='\Drupal\Tests\Listeners\HtmlOutputPrinter' --bootstrap $PWD/$_WEB_ROOT/core/tests/bootstrap.php $test --log-junit $CI_PROJECT_DIR/junit.xml $_PHPUNIT_EXTRA\n "
sudo -u www-data -E vendor/bin/phpunit --no-interaction --printer="\Drupal\Tests\Listeners\HtmlOutputPrinter" --bootstrap $PWD/$_WEB_ROOT/core/tests/bootstrap.php $test --log-junit $CI_PROJECT_DIR/junit.xml $_PHPUNIT_EXTRA || EXIT_CODE=$?
printf "$DIVIDER\n_PHPUNIT_CONCURRENT=$_PHPUNIT_CONCURRENT, executing: sudo -u www-data -E vendor/bin/phpunit $PHPUNIT_OPTIONS --bootstrap $PWD/$_WEB_ROOT/core/tests/bootstrap.php $test --log-junit $CI_PROJECT_DIR/junit.xml $_PHPUNIT_EXTRA\n "
sudo -u www-data -E vendor/bin/phpunit $PHPUNIT_OPTIONS --bootstrap $PWD/$_WEB_ROOT/core/tests/bootstrap.php $test --log-junit $CI_PROJECT_DIR/junit.xml $_PHPUNIT_EXTRA || EXIT_CODE=$?
elif [ "$_PHPUNIT_CONCURRENT" == "1" ]; then
printf "$DIVIDER\n_PHPUNIT_CONCURRENT=$_PHPUNIT_CONCURRENT, executing: sudo SYMFONY_DEPRECATIONS_HELPER='$SYMFONY_DEPRECATIONS_HELPER' MINK_DRIVER_ARGS_WEBDRIVER='$MINK_DRIVER_ARGS_WEBDRIVER' -u www-data php $_WEB_ROOT/core/scripts/run-tests.sh --color --keep-results --concurrency '32' --repeat '1' --sqlite 'sites/default/files/.sqlite' --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --xml $CI_PROJECT_DIR/$_WEB_ROOT/sites/default/files/simpletest --verbose --non-html --file $test $_PHPUNIT_EXTRA\n "
sudo SYMFONY_DEPRECATIONS_HELPER="$SYMFONY_DEPRECATIONS_HELPER" MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php $_WEB_ROOT/core/scripts/run-tests.sh --color --keep-results --concurrency "32" --repeat "1" --sqlite "sites/default/files/.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --xml $CI_PROJECT_DIR/$_WEB_ROOT/sites/default/files/simpletest --verbose --non-html --file $test $_PHPUNIT_EXTRA || EXIT_CODE=$?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment