From 4e0119ce48556c22a640b4912b82b8efaa2aac29 Mon Sep 17 00:00:00 2001 From: User7142 <5984280+User7142@users.noreply.github.com> Date: Tue, 20 Oct 2026 16:53:48 +0200 Subject: [PATCH 1/2] test: cover parallel group-filtered runs whose workers end on fully filtered files A worker's serialized TestResult only carries the `numberOfTests` of the last file it executed. When that file has all of its tests excluded by `--group`/`--exclude-group`, the merged result used to claim the suite was empty and the run exited 1 despite a green summary (PHPUnit enables `failOnEmptyTestSuite` implicitly for explicit test selections). 942d6aea fixed this in `WrapperRunner::numberOfTestsSeenByWorker()`; these tests pin the behaviour: - with `--processes=1` the single worker deterministically ends on ZTest.php, whose only test is outside the filtered group, so the run must exit 0 (fails when the fix is reverted) - a selection that matches no tests at all must still exit non-zero Refs #1483 --- .../ParallelGroupFilteredLastFile/ATest.php | 5 ++++ .../ParallelGroupFilteredLastFile/ZTest.php | 5 ++++ tests/Visual/Parallel.php | 25 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/Fixtures/Suites/ParallelGroupFilteredLastFile/ATest.php create mode 100644 tests/Fixtures/Suites/ParallelGroupFilteredLastFile/ZTest.php diff --git a/tests/Fixtures/Suites/ParallelGroupFilteredLastFile/ATest.php b/tests/Fixtures/Suites/ParallelGroupFilteredLastFile/ATest.php new file mode 100644 index 000000000..16b1f5b3f --- /dev/null +++ b/tests/Fixtures/Suites/ParallelGroupFilteredLastFile/ATest.php @@ -0,0 +1,5 @@ +toBeTrue(); +})->group('filtered'); diff --git a/tests/Fixtures/Suites/ParallelGroupFilteredLastFile/ZTest.php b/tests/Fixtures/Suites/ParallelGroupFilteredLastFile/ZTest.php new file mode 100644 index 000000000..126c80243 --- /dev/null +++ b/tests/Fixtures/Suites/ParallelGroupFilteredLastFile/ZTest.php @@ -0,0 +1,5 @@ +toBeTrue(); +}); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index a775c9926..ada2fa1ce 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -56,3 +56,28 @@ ->toContain('Tests: 2 passed (2 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows(); + +test('parallel group-filtered run is not considered empty when a worker ends on a fully filtered file', function (): void { + $process = new Process( + ['php', 'bin/pest', '--parallel', '--processes=1', '--group=filtered', 'tests/Fixtures/Suites/ParallelGroupFilteredLastFile'], + dirname(__DIR__, 2), + ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true', 'PAO_DISABLE' => '1'], + ); + + $process->run(); + + expect(removeAnsiEscapeSequences($process->getOutput()))->toContain('Tests: 1 passed (1 assertions)') + ->and($process->getExitCode())->toBe(0); +})->skipOnWindows(); + +test('parallel group-filtered run still fails when the selection matches no tests', function (): void { + $process = new Process( + ['php', 'bin/pest', '--parallel', '--processes=3', '--group=missing', 'tests/Fixtures/Suites/ParallelGroupFilteredLastFile'], + dirname(__DIR__, 2), + ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true', 'PAO_DISABLE' => '1'], + ); + + $process->run(); + + expect($process->getExitCode())->not->toBe(0); +})->skipOnWindows(); From e665fb2509f67ab90162928600067929732f17af Mon Sep 17 00:00:00 2001 From: User7142 <5984280+User7142@users.noreply.github.com> Date: Sat, 7 Nov 2026 19:26:13 +0100 Subject: [PATCH 2/2] test: assert the empty-selection message and update the success snapshot The empty-selection case now also expects `No tests found.` and exit code 1, so it no longer passes when the run fails for an unrelated reason. `tests/.snapshots/success.txt` gains the two new tests of `tests/Visual/Parallel.php`. --- tests/.snapshots/success.txt | 4 +++- tests/Visual/Parallel.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 39bd3f9e4..de896b1d3 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -2288,6 +2288,8 @@ ✓ parallel records the test run history ✓ parallel does not record the test run history when asked not to with ('--do-not-cache-result') ✓ parallel does not record the test run history when asked not to with ('--do-not-record-test-run-history') + ✓ parallel group-filtered run is not considered empty when a worker ends on a fully filtered file + ✓ parallel group-filtered run still fails when the selection matches no tests PASS Tests\Visual\ParallelNestedDatasets ✓ parallel loads nested datasets from nested directories @@ -2321,4 +2323,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, 37 skipped, 1648 passed (3649 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 37 skipped, 1650 passed (3653 assertions) \ No newline at end of file diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 77dde10a3..3b5919264 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -128,5 +128,6 @@ $process->run(); - expect($process->getExitCode())->not->toBe(0); + expect(removeAnsiEscapeSequences($process->getOutput()))->toContain('No tests found.') + ->and($process->getExitCode())->toBe(1); })->skipOnWindows();