mirror of
https://github.com/pestphp/pest.git
synced 2026-12-05 23:32:17 +01:00
test: cover parallel group-filtered runs whose workers end on fully filtered files (#1985)
* 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
* 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`.
This commit is contained in:
@@ -105,3 +105,29 @@ test('parallel does not record the test run history when asked not to', function
|
||||
'--do-not-cache-result',
|
||||
'--do-not-record-test-run-history',
|
||||
])->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(removeAnsiEscapeSequences($process->getOutput()))->toContain('No tests found.')
|
||||
->and($process->getExitCode())->toBe(1);
|
||||
})->skipOnWindows();
|
||||
|
||||
Reference in New Issue
Block a user