Skip to content

[4.x] Fixes --processes argument combined with sharding#1473

Closed
adamjsturge wants to merge 2 commits intopestphp:4.xfrom
adamjsturge:fixProcess
Closed

[4.x] Fixes --processes argument combined with sharding#1473
adamjsturge wants to merge 2 commits intopestphp:4.xfrom
adamjsturge:fixProcess

Conversation

@adamjsturge
Copy link
Copy Markdown

What:

  • Bug Fix
  • New Feature

Description:

Fixes #1454

When you try to use sharding since it has to see what tests, process is an illegal argument for that. I tried adding it to the array that filters out parallel, but it doesn't work because of the = i think. So I made a simple filter to get it

@adamjsturge
Copy link
Copy Markdown
Author

@nunomaduro are you able to review this? This has been a blocker for my organization for a little bit and really hoping we can get this fix out

Comment thread src/Plugins/Shard.php
Comment thread src/Plugins/Shard.php Outdated
$filtered = [];
$skipNext = false;

foreach ($arguments as $argument) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamjsturge
I’ve put together a slightly optimized version of the logic to make it more concise by using array_filter and avoiding manual array building.
This helps keep the code a bit cleaner and easier to maintain.

    return array_values(array_filter($arguments, function (string $argument) {

        if (str_starts_with($argument, '--processes') && str_contains($argument, '=')) {
            return false;
        }

        static $skipNext = false;
        if ($skipNext) {
            $skipNext = false;
            return false;
        }

        if ($argument === '--processes') {
            $skipNext = true;
            return false;
        }

        return true;
    }));

@adamjsturge
Copy link
Copy Markdown
Author

@sonalidudhia Thanks for your comments, hopefully you are happy with how I addressed them!

@optii
Copy link
Copy Markdown

optii commented Oct 14, 2025

Any news on when this will land ? We are waiting on this for our test pipelines. If there is anything I can do to help get this through, let me know.

@odinns
Copy link
Copy Markdown
Collaborator

odinns commented Jan 29, 2026

I just encountered this problem when I tried to combine sharding with parallel testing.

@adamjsturge Would this fix make it possible to run each shard in parallel mode?

@adamjsturge
Copy link
Copy Markdown
Author

I just encountered this problem when I tried to combine sharding with parallel testing.

@adamjsturge Would this fix make it possible to run each shard in parallel mode?

Parallel mode and sharding should still work but when you add processes to sharding it breaks.

@nunomaduro nunomaduro changed the title Fix Processes on Sharding [4.x] Fixes --processes argument combined with sharding Apr 10, 2026
@nunomaduro
Copy link
Copy Markdown
Member

Can you rewrite this pull request in a way that you specify the arguments to be removed like:

$this->removeParallelArguments(['--parallel', '-p', '--processes']);

Or something similar? Resubmit the PR after.

@nunomaduro nunomaduro closed this Apr 10, 2026
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.

[Bug]: Pest 4: Unknown option "--processes" when Using Sharding

5 participants