fix: parallel runs with group filters no longer exit 1 despite green tests#1757
Open
User7142 wants to merge 1 commit into
Open
fix: parallel runs with group filters no longer exit 1 despite green tests#1757User7142 wants to merge 1 commit into
User7142 wants to merge 1 commit into
Conversation
…tests In parallel mode each wrapper worker's serialized TestResult only carries the `numberOfTests` of the *last* file it executed — PHPUnit's Collector overwrites the counter on every `executionStarted` event. When a worker's final file has all of its tests excluded by `--group`/`--exclude-group`, that worker reports `hasTests() === false` even though it ran plenty of tests. If every worker happens to end on such a fully-filtered file, the merged TestResult claims the whole suite was empty. Because PHPUnit 12 enables `failOnEmptyTestSuite` implicitly whenever an explicit test selection is present (TextUI\Configuration\Merger), the run then exits 1 — with a fully green summary and no error output whatsoever. Which worker ends on which file is a timing lottery, so this manifests as a flaky, silent CI failure (likely the root cause of pestphp#1483). Fix: while merging worker results, treat a worker that actually ran tests (`numberOfTestsRun() > 0`) as having tests. Genuinely empty selections (no worker ran anything) still exit non-zero. Deterministic reproduction (before this fix): php bin/pest --parallel --processes=1 --group=filtered-group \ tests/.tests/ParallelGroupFilteredLastFile # Tests: 1 passed (1 assertions) — exit code 1 With `--processes=1` the single worker deterministically ends on ZTest.php, whose only test is outside the filtered group.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What:
Description:
--parallelruns that use--group/--exclude-groupcan exit 1 with a fully green summary and no error output.Cause: a wrapper worker's serialized
TestResultonly carries thenumberOfTestsof the last file it executed (PHPUnit'sCollectoroverwrites the counter on everyexecutionStarted). If a worker's final file has all tests excluded by the group filter, it reportshasTests() === falsedespite having run tests. When every worker ends on such a file — a timing lottery, hence flaky — the merged result inWrapperRunner::complete()claims the suite was empty, and since PHPUnit 12 enablesfailOnEmptyTestSuiteimplicitly for explicit selections, the run exits 1. The "No tests found" runner warnings are already filtered from the output, so nothing is printed.Deterministic repro (fails before this fix, passes after — added as a test):
php bin/pest --parallel --processes=1 --group=filtered-group tests/.tests/ParallelGroupFilteredLastFile # "Tests: 1 passed (1 assertions)" — exit code 1Fix: while merging worker results, treat a worker with
numberOfTestsRun() > 0as having tests. A companion test ensures genuinely empty selections still exit non-zero.Related:
--parallelcauses overall process to fail with no reporting as to why even though all tests pass #1483