From ca580736e3ba0cd11108b0f08d4b7c22385f9f70 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Mon, 17 Jun 2024 16:45:55 +0200
Subject: [PATCH] [TASK] Avoid runTests.sh -o
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Inline the 'random seed' option for -s unitRandom,
replay a specific seed using:

> runTests.sh -s unitRandom -- --random-order-seed=<number>

Resolves: #104131
Releases: main, 12.4, 11.5
Change-Id: I84e1cc0a0c57a5132a592a140d1b58ceb6d3b059
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84735
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
---
 Build/Scripts/runTests.sh | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh
index f55f17f6370d..c729cbab58ab 100755
--- a/Build/Scripts/runTests.sh
+++ b/Build/Scripts/runTests.sh
@@ -228,7 +228,7 @@ Options:
             - unit (default): PHP unit tests
             - unitDeprecated: deprecated PHP unit tests
             - unitJavascript: JavaScript unit tests
-            - unitRandom: PHP unit tests in random order, add -o <number> to use specific seed
+            - unitRandom: PHP unit tests in random order, "-- --random-order-seed=<number>" to use specific seed
 
     -b <docker|podman>
         Container environment:
@@ -323,12 +323,6 @@ Options:
         Send xdebug information to a different port than default 9003 if an IDE like PhpStorm
         is not listening on default port.
 
-    -o <number>
-        Only with -s unitRandom
-        Set specific random seed to replay a random run in this order again. The phpunit randomizer
-        outputs the used seed at the end (in gitlab core testing logs, too). Use that number to
-        replay the unit tests in that order.
-
     -n
         Only with -s cgl|cglGit|cglHeader|cglHeaderGit
         Activate dry-run in CGL check that does not actively change files and only prints broken ones.
@@ -352,10 +346,7 @@ Examples:
     ./Build/Scripts/runTests.sh -x -p 8.3 -- --filter filterByValueRecursiveCorrectlyFiltersArray
 
     # Run functional tests in phpunit with a filtered test method name in a specified file
-    # example will currently execute two tests, both of which start with the search term
-    ./Build/Scripts/runTests.sh -s functional -- \
-      --filter datetimeInstanceCanBePersistedToDatabaseIfTypeIsExplicitlySpecified \
-      typo3/sysext/core/Tests/Functional/Database/ConnectionTest.php
+    ./Build/Scripts/runTests.sh -s functional -- --filter aTestName path/to/fileTest.php
 
     # Run functional tests on postgres with xdebug, php 8.3 and execute a restricted set of tests
     ./Build/Scripts/runTests.sh -x -p 8.3 -s functional -d postgres typo3/sysext/core/Tests/Functional/Authentication
@@ -408,7 +399,6 @@ PHP_XDEBUG_PORT=9003
 ACCEPTANCE_HEADLESS=1
 ACCEPTANCE_TOPIC="sets"
 EXTRA_TEST_OPTIONS=""
-PHPUNIT_RANDOM=""
 CGLCHECK_DRY_RUN=""
 DATABASE_DRIVER=""
 CHUNKS=0
@@ -431,7 +421,7 @@ OPTIND=1
 # Array for invalid options
 INVALID_OPTIONS=()
 # Simple option parsing based on getopts (! not getopt)
-while getopts ":a:b:s:c:d:i:t:p:e:xy:o:nhug" OPT; do
+while getopts ":a:b:s:c:d:i:t:p:e:xy:nhug" OPT; do
     case ${OPT} in
         s)
             TEST_SUITE=${OPTARG}
@@ -481,9 +471,6 @@ while getopts ":a:b:s:c:d:i:t:p:e:xy:o:nhug" OPT; do
         y)
             PHP_XDEBUG_PORT=${OPTARG}
             ;;
-        o)
-            PHPUNIT_RANDOM="--random-order-seed=${OPTARG}"
-            ;;
         n)
             CGLCHECK_DRY_RUN="-n"
             ;;
@@ -1084,7 +1071,7 @@ case ${TEST_SUITE} in
         SUITE_EXIT_CODE=$?
         ;;
     unitRandom)
-        ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name unit-random-${SUFFIX} ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${IMAGE_PHP} bin/phpunit -c Build/phpunit/UnitTests.xml --order-by=random ${EXTRA_TEST_OPTIONS} ${PHPUNIT_RANDOM} "$@"
+        ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name unit-random-${SUFFIX} ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${IMAGE_PHP} bin/phpunit -c Build/phpunit/UnitTests.xml --order-by=random ${EXTRA_TEST_OPTIONS} "$@"
         SUITE_EXIT_CODE=$?
         ;;
     update)
-- 
GitLab