[Bug]: --parallel does not handle multiple --exclude-group flags
What Happened
./vendor/bin/pest --exclude-group='foo' --exclude-group='should exclude' --parallel
This only excludes the foo group, causing the should exclude tests to be executed.
How to Reproduce
Using Pest 3.8.3 in a clean workspace, I have modified the ExampleTest as follows:
<?php
test('example', function () {
expect(true)->toBeTrue();
});
test('exclude me', function () {
expect(false)->toBeTrue();
})->group('should exclude');
The test suite when run with --parallel ignores subsequent --exclude-group flags. Scenarios:
-
./vendor/bin/pest --exclude-group='foo,should exclude'-- works fine -
./vendor/bin/pest --exclude-group='foo,should exclude' --parallel-- works fine -
./vendor/bin/pest --exclude-group='foo' --exclude-group='should exclude'-- works fine -
./vendor/bin/pest --exclude-group='foo' --exclude-group='should exclude' --parallel-- only excludes thefoogroup, causing theshould excludetest to be executed
Sample Repository
No response
Pest Version
3.8.3
PHP Version
8.3.24
Operation System
Linux
Notes
No response
Might want to check #1430 which I closed for a workaround if you fork yourself
I had the same issue, source-dived, and found it is related to the way some other plugins - not Parallel - within the plugins pipeline handle arguments.
For example, in src/plugins/Coverage 73-77,
$originals = array_flip($originals);
foreach ($arguments as $argument) {
unset($originals[$argument]);
}
$originals = array_flip($originals);
The code wrongly assumes doing array_flip() twice will result in same array for unchanged items, but non-unique items will be removed from the array.
The problem existed in 3.X but is compounded by PHPUnit 12 deprecated the use of options with multiple values, such as --exclude-group
Wanted to give hints as to the cause. Maybe others with more pest internal knowledge will chime in.
Our team is also facing the same issue. I assumed it was a Paratest issue, but I'm glad to see it's not haha. The inability to handle multiple --exclude-group while also utilizing --parallel breaks our flow and is currently keeping us from upgrading to Pest 4.
Commenting to follow. Experiencing the same issue.
I've created a sample repository.
./vendor/bin/pest --exclude-group=one --exclude-group=two --parallel # Fails
./vendor/bin/pest --exclude-group=one --exclude-group=two # Works
Here's the doc reference for the CLI syntax of multiple group exclusions.
I dove deep and tried to fix it but was unsuccessful. I managed to get failing tests to confirm the bug and happy to open a draft PR to show the failing tests if that'd help @nunomaduro