pest icon indicating copy to clipboard operation
pest copied to clipboard

[Bug]: --parallel does not handle multiple --exclude-group flags

Open glmdev opened this issue 6 months ago • 6 comments

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 the foo group, causing the should exclude test to be executed

Sample Repository

No response

Pest Version

3.8.3

PHP Version

8.3.24

Operation System

Linux

Notes

No response

glmdev avatar Aug 19 '25 15:08 glmdev

Might want to check #1430 which I closed for a workaround if you fork yourself

snellingio avatar Aug 21 '25 02:08 snellingio

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.

flap152 avatar Aug 24 '25 01:08 flap152

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.

ConorEdwardsCP avatar Aug 26 '25 14:08 ConorEdwardsCP

Commenting to follow. Experiencing the same issue.

Junveloper avatar Oct 15 '25 00:10 Junveloper

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.

grantholle avatar Nov 11 '25 20:11 grantholle

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

Junveloper avatar Nov 28 '25 05:11 Junveloper