fix: popArgument drops duplicate arguments breaking --parallel --exclude-gropup= (#1674)

* fix: popArgument drops duplicate arguments breaking --parallel multi-exclude-group

Fixes #1437

* fix: ensure popArgument handles duplicate arguments

* fix: update expected test results and snapshots after rebase

---------

Signed-off-by: nuno maduro <enunomaduro@gmail.com>
Co-authored-by: nuno maduro <enunomaduro@gmail.com>
This commit is contained in:
flap152
2026-06-12 12:58:37 -04:00
committed by GitHub
parent 97714a7088
commit 8467c64c22
5 changed files with 49 additions and 8 deletions

View File

@ -1716,6 +1716,8 @@
✓ method hasArgument with ('someValue', true)
✓ method hasArgument with ('--a', false)
✓ method hasArgument with ('--undefined-argument', false)
✓ popArgument preserves duplicate values when removing a missing argument
✓ popArgument preserves duplicate values when removing an existing argument
PASS Tests\Unit\Plugins\Environment
✓ environment is set to CI when --ci option is used
@ -1913,6 +1915,7 @@
✓ parallel
✓ a parallel test can extend another test with same name
✓ parallel reports invalid datasets as failures
✓ parallel can have multiple exclude-groups
PASS Tests\Visual\ParallelNestedDatasets
✓ parallel loads nested datasets from nested directories
@ -1946,4 +1949,4 @@
✓ pass with dataset with ('my-datas-set-value')
✓ within describe → pass with dataset with ('my-datas-set-value')
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1335 passed (3024 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1332 passed (3014 assertions)

View File

@ -24,3 +24,27 @@ test('method hasArgument', function (string $argument, bool $expectedResult) {
['--a', false],
['--undefined-argument', false],
]);
test('popArgument preserves duplicate values when removing a missing argument', function () {
$obj = new class
{
use HandleArguments;
};
$arguments = ['--verbose', '--exclude-group', 'firstGroup', '--exclude-group', 'secondGroup', '--filter=MyTest'];
$result = $obj->popArgument('--missingitem', $arguments);
expect($result)->toBe($arguments);
});
test('popArgument preserves duplicate values when removing an existing argument', function () {
$obj = new class
{
use HandleArguments;
};
$arguments = ['--verbose', '--exclude-group', 'firstGroup', '--exclude-group', 'secondGroup', '--filter=MyTest'];
$result = $obj->popArgument('--verbose', $arguments);
expect($result)->toBe(['--exclude-group', 'firstGroup', '--exclude-group', 'secondGroup', '--filter=MyTest']);
});

View File

@ -24,7 +24,7 @@ test('parallel', function () use ($run) {
$file = file_get_contents(__FILE__);
$file = preg_replace(
'/\$expected = \'.*?\';/',
"\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1319 passed (2973 assertions)';",
"\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1315 passed (2961 assertions)';",
$file,
);
file_put_contents(__FILE__, $file);
@ -47,3 +47,14 @@ test('parallel reports invalid datasets as failures', function () use ($run) {
->toContain('Tests: 1 failed, 1 passed (1 assertions)')
->toContain('Parallel: 3 processes');
})->skipOnWindows();
test('parallel can have multiple exclude-groups', function () use ($run) {
$singleExclude = $run('--exclude-group=integration');
$doubleExclude = $run('--exclude-group=integration', '--exclude-group=container');
preg_match('/(\d+) passed/', $singleExclude, $singleMatch);
preg_match('/(\d+) passed/', $doubleExclude, $doubleMatch);
expect((int) $doubleMatch[1])->toBeLessThan((int) $singleMatch[1]);
expect($doubleExclude)->toContain('Parallel: 3 processes');
})->skipOnWindows();