From 8a910fe2ea69304066cf1ca69cedcb6440b2b78a Mon Sep 17 00:00:00 2001 From: Lazizbek Ergashev Date: Sat, 27 Jun 2026 02:03:12 +0500 Subject: [PATCH] fix: strip --processes from --list-tests when sharding in parallel --- src/Plugins/Shard.php | 29 ++++++++++++++++++++++++++++- tests/Visual/Parallel.php | 6 ++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Plugins/Shard.php b/src/Plugins/Shard.php index 814125f20..5017d198c 100644 --- a/src/Plugins/Shard.php +++ b/src/Plugins/Shard.php @@ -204,7 +204,34 @@ private function allTests(array $arguments): array */ private function removeParallelArguments(array $arguments): array { - return array_filter($arguments, fn (string $argument): bool => ! in_array($argument, ['--parallel', '-p'], strict: true)); + $filtered = []; + $skipNext = false; + + foreach ($arguments as $argument) { + if ($skipNext) { + $skipNext = false; + + continue; + } + + if (in_array($argument, ['--parallel', '-p'], strict: true)) { + continue; + } + + if ($argument === '--processes') { + $skipNext = true; + + continue; + } + + if (str_starts_with($argument, '--processes=')) { + continue; + } + + $filtered[] = $argument; + } + + return $filtered; } /** diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index d497eef3c..b996adcaa 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -41,6 +41,12 @@ expect($run('tests/Fixtures/Inheritance'))->toContain('Tests: 1 skipped, 1 passed (1 assertions)'); })->skipOnWindows(); +test('a count-based shard runs in parallel when no shards file exists', function () use ($run) { + expect($run('tests/Fixtures/Inheritance', '--shard=1/1')) + ->toContain('Tests: 1 skipped, 1 passed (1 assertions)') + ->toContain('Parallel: 3 processes'); +})->skipOnWindows(); + test('parallel reports invalid datasets as failures', function () use ($run) { expect($run('tests/.tests/ParallelInvalidDataset')) ->toContain("A dataset with the name `missing.dataset` does not exist. You can create it using `dataset('missing.dataset', ['a', 'b']);`.")