Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/Plugins/Shard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/Visual/Parallel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);`.")
Expand Down