Repository navigation
Improve failure description - #6557
sebastianbergmann wants to merge 2 commits into
Conversation
|
@sebastianfeldmann @edorian Can you have a look, please? Thank you! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 12.5 #6557 +/- ##
=========================================
Coverage 95.93% 95.94%
- Complexity 7462 7476 +14
=========================================
Files 790 790
Lines 22800 22842 +42
=========================================
+ Hits 21874 21916 +42
Misses 926 926 ☔ View full report in Codecov by Sentry. |
findAnchorInActual() only returns a position where the literal or regular expression check already passed, so the conditional is unnecessary.
|
Tested it against my .phpt test suites and everything works well. The "%A" match failures that are common for us that I remembered and tested didn't change in output. The tests look a lot nicer and the algo looks a lot more sensible than before. All around 👍 from me @sebastianbergmann |
|
Cherry-picked into |
|
Nice idea with the freshly synced array 👍 All tests in my local branch passed as well. I will check if it makes sense to still commit the tests. |
Improve the failure description for the
StringMatchesFormatDescriptionconstraint when%a/%Amultiline placeholders match content spanning multiple lines.Previously,
additionalFailureDescription()compared expected and actual output line-by-line using a single shared index. When%aor%Aconsumed multiple actual lines, the arrays went out of sync and all subsequent lines appeared as false diffs — burying the real failure in noise.This was attempted before in 72ea2b5 by modifying
regularExpressionForFormatDescription()to remove the$end-of-string anchor for multiline patterns.That approach caused regression #6200 because
regularExpressionForFormatDescription()is shared withmatches(), which changed test pass/fail outcomes. It was reverted in 9bd312d.This implementation takes a different approach that avoids the regression:
additionalFailureDescription()matches()andregularExpressionForFormatDescription()are unchanged%a/%Aline is encountered, find the next non-multiline expected line (the "anchor") and search for it in the actual output to determine how many lines the placeholder consumedarray_splice()Before (multiline
%Acauses full desync):After (only the real mismatch is shown):