fix: handle AfterLastTestMethodErrored in StateGenerator for parallel mode#1627
Open
QDenka wants to merge 167 commits intopestphp:3.xfrom
Open
fix: handle AfterLastTestMethodErrored in StateGenerator for parallel mode#1627QDenka wants to merge 167 commits intopestphp:3.xfrom
QDenka wants to merge 167 commits intopestphp:3.xfrom
Conversation
Co-authored-by: Owen Voke <development@voke.dev>
Co-authored-by: Owen Voke <development@voke.dev>
…r describe blocks with the same name
The functions toMatchArray and toMatchObject indicate that the wrong field is mismatching from the second loop on because the 'message' is overwritten and taken into the following loop. This patch creates a $second_message for the second test (value test) to keep the error message correct.
Remove remaining } in toMatchObject.
Reset approach was not the right one.
[WIP] Feat: PHPUnit 12
…ning Fix Undefined array key "testdox-columns" warning
ci: bump actions/checkout 4 => 5
[4.x] Bump checkout version from 5 to 6
…-help feat: add --dirty documentation in --help
feat: show more useful exception when `intl` extension not found
…y-file-level feat: add pest only function to mark each test in a file as only
Removed and updated sponsor links in the README.
…e-this Specify closure this for extend
…ultibyte string compatibility and correct TeamCity test names for datasets in "describe" blocks
…-tests-with-dataset fix: replace `substr` with `mb_substr` in Str::beforeLast to ensure multibyte string compatibility and correct TeamCity test names for datasets in "describe" blocks
… mode Previously, StateGenerator assumed all non-Errored events from testErroredEvents() were BeforeFirstTestMethodErrored. However, AfterLastTestMethodErrored events can also appear (e.g., when errors occur during teardown), causing a TypeError crash in parallel mode. This adds explicit instanceof checks for both BeforeFirstTestMethodErrored and AfterLastTestMethodErrored, converting the latter to a BeforeFirstTestMethodErrored for display purposes since both share the same interface. Fixes pestphp#1623
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.
Problem
When running tests in parallel mode (
--parallel), if any test triggers anAfterLastTestMethodErroredevent (e.g., errors during teardown/cleanup), Pest crashes with aTypeError:This happens because
StateGeneratorassumes all non-Erroredevents fromtestErroredEvents()areBeforeFirstTestMethodErrored, butAfterLastTestMethodErroredevents can also be present.Solution
Added explicit
instanceofchecks for bothBeforeFirstTestMethodErroredandAfterLastTestMethodErrored. Since both event types share the same interface (testClassName(),calledMethod(),throwable(),telemetryInfo()),AfterLastTestMethodErroredis converted to aBeforeFirstTestMethodErroredfor display purposes via Collision'sTestResult::fromBeforeFirstTestMethodErrored().Changes
src/Support/StateGenerator.php: Addedinstanceofchecks forBeforeFirstTestMethodErroredandAfterLastTestMethodErroredinstead of a catch-allelsebranchtests/Unit/Support/StateGenerator.php: Added tests verifying both event types are handled correctly without TypeErrorFixes #1623