From fc840e4c2561e49f589957c00ff8c00020242c96 Mon Sep 17 00:00:00 2001 From: michalsn Date: Thu, 2 Apr 2026 15:31:13 +0200 Subject: [PATCH 1/5] fix: make Autoloader composer path injectable to fix parallel test race condition --- system/Autoloader/Autoloader.php | 14 +++++++++----- tests/system/Autoloader/AutoloaderTest.php | 7 +------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index 65c535e8611e..b9bbad230873 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -93,6 +93,10 @@ class Autoloader */ protected $helpers = ['url']; + public function __construct(private string $composerPath = COMPOSER_PATH) + { + } + /** * Reads in the configuration array (described above) and stores * the valid parts that we'll need. @@ -127,7 +131,7 @@ public function initialize(Autoload $config, Modules $modules) $this->helpers = [...$this->helpers, ...$config->helpers]; } - if (is_file(COMPOSER_PATH)) { + if (is_file($this->composerPath)) { $this->loadComposerAutoloader($modules); } @@ -139,11 +143,11 @@ private function loadComposerAutoloader(Modules $modules): void // The path to the vendor directory. // We do not want to enforce this, so set the constant if Composer was used. if (! defined('VENDORPATH')) { - define('VENDORPATH', dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR); + define('VENDORPATH', dirname($this->composerPath) . DIRECTORY_SEPARATOR); } /** @var ClassLoader $composer */ - $composer = include COMPOSER_PATH; + $composer = include $this->composerPath; // Should we load through Composer's namespaces, also? if ($modules->discoverInComposer) { @@ -451,14 +455,14 @@ private function loadComposerNamespaces(ClassLoader $composer, array $composerPa */ protected function discoverComposerNamespaces() { - if (! is_file(COMPOSER_PATH)) { + if (! is_file($this->composerPath)) { return; } /** * @var ClassLoader $composer */ - $composer = include COMPOSER_PATH; + $composer = include $this->composerPath; $paths = $composer->getPrefixesPsr4(); $classes = $composer->getClassMap(); diff --git a/tests/system/Autoloader/AutoloaderTest.php b/tests/system/Autoloader/AutoloaderTest.php index cd73356958fe..ef76091baa39 100644 --- a/tests/system/Autoloader/AutoloaderTest.php +++ b/tests/system/Autoloader/AutoloaderTest.php @@ -367,17 +367,12 @@ public function testComposerPackagesOnlyAndExclude(): void public function testFindsComposerRoutesWithComposerPathNotFound(): void { - $composerPath = COMPOSER_PATH; - $config = new Autoload(); $modules = new Modules(); $modules->discoverInComposer = true; - $loader = new Autoloader(); - - rename(COMPOSER_PATH, COMPOSER_PATH . '.backup'); + $loader = new Autoloader('/nonexistent/path/autoload.php'); $loader->initialize($config, $modules); - rename(COMPOSER_PATH . '.backup', $composerPath); $namespaces = $loader->getNamespace(); $this->assertArrayNotHasKey('Laminas\\Escaper', $namespaces); From 5085fd9a3a272e14ea8c526df0efbdc47507ec16 Mon Sep 17 00:00:00 2001 From: michalsn Date: Thu, 2 Apr 2026 15:34:58 +0200 Subject: [PATCH 2/5] fix: locale-dependent printf in run-random-tests.sh --- .github/scripts/run-random-tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/run-random-tests.sh b/.github/scripts/run-random-tests.sh index 45376fb58fb2..23a90f955e2f 100755 --- a/.github/scripts/run-random-tests.sh +++ b/.github/scripts/run-random-tests.sh @@ -23,6 +23,7 @@ ################################################################################ set -u +export LC_NUMERIC=C trap 'kill "${bg_pids[@]:-}" 2>/dev/null; wait 2>/dev/null' EXIT INT TERM ################################################################################ From e5140d59fe4fcfdb013d7bbc692740bdaa38588d Mon Sep 17 00:00:00 2001 From: michalsn Date: Thu, 2 Apr 2026 15:46:20 +0200 Subject: [PATCH 3/5] fix rector --- system/Autoloader/Autoloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index b9bbad230873..69906d4e162a 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -93,7 +93,7 @@ class Autoloader */ protected $helpers = ['url']; - public function __construct(private string $composerPath = COMPOSER_PATH) + public function __construct(private readonly string $composerPath = COMPOSER_PATH) { } From 5e0ea9857cae95d256ed251d76f1b66d8aae54b6 Mon Sep 17 00:00:00 2001 From: michalsn Date: Thu, 2 Apr 2026 16:32:58 +0200 Subject: [PATCH 4/5] add an option to automatically show failures details in GA --- .github/scripts/run-random-tests.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/scripts/run-random-tests.sh b/.github/scripts/run-random-tests.sh index 23a90f955e2f..562bfd355962 100755 --- a/.github/scripts/run-random-tests.sh +++ b/.github/scripts/run-random-tests.sh @@ -10,6 +10,7 @@ # Usage: ./run-random-tests.sh [options] # Options: # -q, --quiet Suppress debug output +# -f, --show-failures Print failed test output in summary (auto-enabled in GitHub Actions) # -c, --component COMPONENT Test single COMPONENT (overrides config file) # -n, --max-jobs MAX_JOBS Limit concurrent test jobs (auto-detect if omitted) # -r, --repeat REPEAT Repeat full component run REPEAT times @@ -52,6 +53,7 @@ component="" max_jobs="" repeat_count=1 timeout_seconds=300 +show_failures="" first_result=true declare -a bg_pids=() @@ -277,6 +279,10 @@ parse_arguments() { quiet="--quiet" shift ;; + -f|--show-failures) + show_failures="--show-failures" + shift + ;; -c|--component) if [[ $# -lt 2 ]]; then print_error "Missing value for --component" @@ -344,6 +350,7 @@ show_help() { echo "" echo -e "${YELLOW}Options:${RESET}" echo -e " ${GREEN}-q, --quiet${RESET} Suppress debug output" + echo -e " ${GREEN}-f, --show-failures${RESET} Print failed test output in summary (auto-enabled in GitHub Actions)" echo -e " ${GREEN}-c, --component COMPONENT${RESET} Test single ${GREEN}COMPONENT${RESET} (overrides config file)" echo -e " ${GREEN}-n, --max-jobs MAX_JOBS${RESET} Limit concurrent test jobs (auto-detect if omitted)" echo -e " ${GREEN}-r, --repeat REPEAT${RESET} Repeat full component run ${GREEN}REPEAT${RESET} times" @@ -758,6 +765,18 @@ print_summary() { fi echo -e " ${RED}✗${RESET} ${BOLD}$failed_component${RESET} ($result_file)" + + if [[ -n "${GITHUB_ACTIONS:-}" || "$show_failures" == "--show-failures" ]]; then + if [[ -f "$result_file" ]]; then + if [[ -n "${GITHUB_ACTIONS:-}" ]]; then + echo "::group::Output: $failed_component" + fi + cat "$result_file" + if [[ -n "${GITHUB_ACTIONS:-}" ]]; then + echo "::endgroup::" + fi + fi + fi done < <(printf '%s\n' "${failed_components[@]}" | sort) fi From 9393a4fe777aeba25dcaf8d502bc52442779502b Mon Sep 17 00:00:00 2001 From: michalsn Date: Thu, 2 Apr 2026 18:50:13 +0200 Subject: [PATCH 5/5] Revert "add an option to automatically show failures details in GA" This reverts commit cb71e0ffed3423fbebf52469753a57ec620cc586. --- .github/scripts/run-random-tests.sh | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/scripts/run-random-tests.sh b/.github/scripts/run-random-tests.sh index 562bfd355962..23a90f955e2f 100755 --- a/.github/scripts/run-random-tests.sh +++ b/.github/scripts/run-random-tests.sh @@ -10,7 +10,6 @@ # Usage: ./run-random-tests.sh [options] # Options: # -q, --quiet Suppress debug output -# -f, --show-failures Print failed test output in summary (auto-enabled in GitHub Actions) # -c, --component COMPONENT Test single COMPONENT (overrides config file) # -n, --max-jobs MAX_JOBS Limit concurrent test jobs (auto-detect if omitted) # -r, --repeat REPEAT Repeat full component run REPEAT times @@ -53,7 +52,6 @@ component="" max_jobs="" repeat_count=1 timeout_seconds=300 -show_failures="" first_result=true declare -a bg_pids=() @@ -279,10 +277,6 @@ parse_arguments() { quiet="--quiet" shift ;; - -f|--show-failures) - show_failures="--show-failures" - shift - ;; -c|--component) if [[ $# -lt 2 ]]; then print_error "Missing value for --component" @@ -350,7 +344,6 @@ show_help() { echo "" echo -e "${YELLOW}Options:${RESET}" echo -e " ${GREEN}-q, --quiet${RESET} Suppress debug output" - echo -e " ${GREEN}-f, --show-failures${RESET} Print failed test output in summary (auto-enabled in GitHub Actions)" echo -e " ${GREEN}-c, --component COMPONENT${RESET} Test single ${GREEN}COMPONENT${RESET} (overrides config file)" echo -e " ${GREEN}-n, --max-jobs MAX_JOBS${RESET} Limit concurrent test jobs (auto-detect if omitted)" echo -e " ${GREEN}-r, --repeat REPEAT${RESET} Repeat full component run ${GREEN}REPEAT${RESET} times" @@ -765,18 +758,6 @@ print_summary() { fi echo -e " ${RED}✗${RESET} ${BOLD}$failed_component${RESET} ($result_file)" - - if [[ -n "${GITHUB_ACTIONS:-}" || "$show_failures" == "--show-failures" ]]; then - if [[ -f "$result_file" ]]; then - if [[ -n "${GITHUB_ACTIONS:-}" ]]; then - echo "::group::Output: $failed_component" - fi - cat "$result_file" - if [[ -n "${GITHUB_ACTIONS:-}" ]]; then - echo "::endgroup::" - fi - fi - fi done < <(printf '%s\n' "${failed_components[@]}" | sort) fi