Skip to content

Commit 8a910fe

Browse files
committed
fix: strip --processes from --list-tests when sharding in parallel
1 parent ee2e97e commit 8a910fe

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/Plugins/Shard.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,34 @@ private function allTests(array $arguments): array
204204
*/
205205
private function removeParallelArguments(array $arguments): array
206206
{
207-
return array_filter($arguments, fn (string $argument): bool => ! in_array($argument, ['--parallel', '-p'], strict: true));
207+
$filtered = [];
208+
$skipNext = false;
209+
210+
foreach ($arguments as $argument) {
211+
if ($skipNext) {
212+
$skipNext = false;
213+
214+
continue;
215+
}
216+
217+
if (in_array($argument, ['--parallel', '-p'], strict: true)) {
218+
continue;
219+
}
220+
221+
if ($argument === '--processes') {
222+
$skipNext = true;
223+
224+
continue;
225+
}
226+
227+
if (str_starts_with($argument, '--processes=')) {
228+
continue;
229+
}
230+
231+
$filtered[] = $argument;
232+
}
233+
234+
return $filtered;
208235
}
209236

210237
/**

tests/Visual/Parallel.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
expect($run('tests/Fixtures/Inheritance'))->toContain('Tests: 1 skipped, 1 passed (1 assertions)');
4242
})->skipOnWindows();
4343

44+
test('a count-based shard runs in parallel when no shards file exists', function () use ($run) {
45+
expect($run('tests/Fixtures/Inheritance', '--shard=1/1'))
46+
->toContain('Tests: 1 skipped, 1 passed (1 assertions)')
47+
->toContain('Parallel: 3 processes');
48+
})->skipOnWindows();
49+
4450
test('parallel reports invalid datasets as failures', function () use ($run) {
4551
expect($run('tests/.tests/ParallelInvalidDataset'))
4652
->toContain("A dataset with the name `missing.dataset` does not exist. You can create it using `dataset('missing.dataset', ['a', 'b']);`.")

0 commit comments

Comments
 (0)