Skip to content

Fix --parallel dropping options#1620

Open
flap152 wants to merge 2 commits intopestphp:4.xfrom
flap152:fix-argument-pop
Open

Fix --parallel dropping options#1620
flap152 wants to merge 2 commits intopestphp:4.xfrom
flap152:fix-argument-pop

Conversation

@flap152
Copy link

@flap152 flap152 commented Jan 29, 2026

What:

  • Bug Fix
  • New Feature

Description:

This PR fixes issue 1437 where additional --exlude-group options were ignored when using --parallel flag.
It's a much smaller version of PR 1468. This PR doesn't bring the additional tests to avoid changes to Visual test snapshots, but the proof of the problem and fix is available with a single statement given below.

Problem:

In version 3.x and 4.0, running tests with --parallel using multiple --exclude-group options, only the first option was used.
This probably applies to other multiple-use options such as --group.
This problem is made worse in v4.0 using PHPUnit 12, forcing the use of multiple option vs comma-separated list.

Root Cause:

Some plugin argument handlers remove an argument from the $arguments array by using array_flip() twice. They wrongly assume the remaining array is unchanged, but any non-unique value is removed from the array.

This breaks Parallel because long options (--option=value) in the argument array appear as two items (['--option','value']) causing potential duplicate keys.

Why does it work when not using --parallel?

The non-parallel worker avoids duplicate keys in the argument pipeline by keeping option and value together in the array (['--option=value']).

Solution:

Modified popArgument() in HandleArguments Trait to use unset() instead of the double array_flip()
Modified Coverage plugin to use the Trait method instead of its own double array_flip() code.

Testing:

This PR does not add new tests to avoid changes in "Visual" tests.
The following statement should not fail and simply return null, but it does fail on 4.x branch without this PR

PHPUnit\Framework\assertEquals((new class {use Pest\Plugins\Concerns\HandleArguments;})->popArgument('anything',['same', 'same']),['same', 'same']);

Related:

Fixes issue 1437
Better version of PR 1468

…uments.

Not making new tests to avoid changes in "Visual" tests.
The following statement should not fail and simply return null:
   PHPUnit\Framework\assertEquals((new class {use Pest\Plugins\Concerns\HandleArguments;})->popArgument('anything',['same', 'same']),['same', 'same']);
…gument handling logic

- This fixes duplicate argument exclusion with --parallel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant