fix(sharding): strip every paratest-only option from the --list-tests sub-process (#2076)

* fix(sharding): strip every paratest-only option from the `--list-tests` sub-process

`--update-shards` (and `--shard` without a shards.json) discovers the test classes by
re-running Pest with `--list-tests`. That sub-process is a plain PHPUnit run, but only
`--parallel`, `-p`, `--processes` and `--runner` were removed from its arguments, so any
other ParaTest option killed the run before a single test:

    pest --parallel --update-shards --max-batch-size=100
    Unknown option "--max-batch-size".

Strip every option ParaTest defines that PHPUnit does not (`--max-batch-size`/`-m`,
`--max-processes`, `--passthru-php`, `--tmp-dir`, `--functional`, `--no-test-tokens`,
plus the existing `--processes` and `--runner`), in both `--option=value` and
`--option value` form.

* fix(sharding): strip ParaTest's `-m` with its value attached (`-m100`)

ParaTest reads `-m100` as `--max-batch-size=100`, but the option check split
arguments on `=` only, so the attached form reached PHPUnit's `--list-tests`
sub-process, which rejects `-m`. `-p` is left alone: Pest reads it as
`--parallel`.

---------

Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
This commit is contained in:
Bartłomiej Gajda
2026-11-27 07:24:04 +01:00
committed by GitHub
parent 249a120d89
commit fa6e96486e
4 changed files with 86 additions and 11 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ test('parallel', function () use ($run): void {
$output = implode("\n", array_slice(explode("\n", (string) $output), -10));
$profileOutput = $run('tests/Fixtures/Suites/SuccessOnly.php', '--profile');
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 31 skipped, 1850 passed (3949 assertions)';
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 31 skipped, 1861 passed (3960 assertions)';
expect($output)
->toContain("Tests: {$expected}")