From cf205875751fb1c7ce7e7ff1998918e107ea1fbc Mon Sep 17 00:00:00 2001 From: Lazizbek Ergashev Date: Fri, 13 Nov 2026 17:33:05 +0500 Subject: [PATCH] fix: support brianium/paratest 7.28 grouped test files (#2025) --- composer.json | 2 +- .../Parallel/Paratest/WrapperRunner.php | 45 +++++++++++++------ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index d0f116c1..135e50dd 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": "^8.4", - "brianium/paratest": "^7.27.5", + "brianium/paratest": "^7.28.0", "nunomaduro/collision": "^8.9.5", "nunomaduro/termwind": "^2.4.0", "pestphp/pest-plugin": "^5.0.0", diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 0b54e20c..66036fdb 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -75,7 +75,7 @@ final class WrapperRunner implements RunnerInterface private readonly Timer $timer; - /** @var list */ + /** @var list> */ private array $pending = []; private int $exitcode = -1; @@ -248,7 +248,7 @@ final class WrapperRunner implements RunnerInterface $this->flushWorker($worker); - if ($batchSize !== 0 && $this->batches[$token] === $batchSize) { + if ($batchSize !== 0 && $this->batches[$token] >= $batchSize) { $this->destroyWorker($token); $worker = $this->startWorker($token); } @@ -260,7 +260,7 @@ final class WrapperRunner implements RunnerInterface $this->pending = []; } elseif (($pending = array_shift($this->pending)) !== null) { $worker->assign($pending); - $this->batches[$token]++; + $this->batches[$token] += count($pending); } } @@ -635,19 +635,34 @@ final class WrapperRunner implements RunnerInterface } /** - * @return array + * @return list> */ private function getTestFiles(SuiteLoader $suiteLoader): array { - /** @var array $files */ + /** @var array $files */ $files = []; - foreach (array_filter( - $suiteLoader->tests, - fn (string $filename): bool => ! str_ends_with($filename, "eval()'d code") - ) as $filename) { - $resolved = realpath($filename) ?: $filename; - $files[$resolved] = null; + /** @var list> $groups */ + $groups = []; + + foreach ($suiteLoader->tests as $tests) { + $group = []; + + foreach (array_filter( + $tests, + fn (string $filename): bool => ! str_ends_with($filename, "eval()'d code") + ) as $filename) { + $resolved = realpath($filename) ?: $filename; + + if (! isset($files[$resolved])) { + $files[$resolved] = true; + $group[] = $resolved; + } + } + + if ($group !== []) { + $groups[] = $group; + } } foreach (TestSuite::getInstance()->tests->getFilenames() as $filename) { @@ -655,11 +670,15 @@ final class WrapperRunner implements RunnerInterface $resolved = realpath($filename) ?: realpath($this->options->cwd.DIRECTORY_SEPARATOR.$filename) ?: $filename; - $files[$resolved] = null; + + if (! isset($files[$resolved])) { + $files[$resolved] = true; + $groups[] = [$resolved]; + } } } - return array_keys($files); + return $groups; } private function shouldIncludeBootstrappedTestFile(string $filename): bool