refactor(xcresult): name the places a test's file can come from - #1158
Merged
Conversation
The file we report for a failed test was assembled by an `.or_else` chain of `Option<String>`, where every link meant something different and none of them said so. `fileName` is the site an assertion fired, which for a helper is the helper's file; the call-stack fallback is whichever frame happened to be outermost. Reading the chain, they are indistinguishable. `FileSource` names each place we look and `FileCandidate` carries it alongside the path, so a candidate can be traced back to where it came from instead of arriving as an anonymous string. The extraction for each source moves into `file_attribution` as its own named function, and the module doc says the thing the code could not: an `.xcresult` records where a failure was *raised*, never where a test is *declared*, so every source here is a proxy for the question we are actually asking. `ReportedPath` normalizes once at construction. It was previously applied by hand at each call site, which is a silent bug the moment one is missed or two paths are compared having been normalized differently. No behaviour change: the sources are offered in the order the chain tried them and the first is taken. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
😎 This pull request was merged. |
This was referenced Aug 18, 2026
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1158 +/- ##
==========================================
+ Coverage 82.97% 83.28% +0.31%
==========================================
Files 71 72 +1
Lines 16044 16110 +66
==========================================
+ Hits 13312 13417 +105
+ Misses 2732 2693 -39 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
TylerJang27
approved these changes
Aug 19, 2026
|
This pull request was merged into |
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.
Stack 1/3 — no behaviour change.
The file we report for a failed test was assembled by an
.or_elsechain ofOption<String>, where every link meant something different and none of them said so.fileNameis the site an assertion fired, which for a helper is the helper's file; the call-stack fallback is whichever frame happened to be outermost. Reading the chain, they are indistinguishable.This adds the vocabulary:
FileSource— one variant per place we look, each documented with what it actually meansFileCandidate— carries the source alongside the path, so a candidate can be traced back to where it came from instead of arriving as an anonymous stringReportedPath— normalizes once at construction. It was previously applied by hand at each call site, which is a silent bug the moment one is missed, or two paths are compared having been normalized differently.Each source's extraction moves into a new
file_attributionmodule as its own named function. The module doc states the thing the code could not: an.xcresultrecords where a failure was raised, never where a test is declared, so every source here is a proxy for the question we are actually asking — and the answer is what codeowners get resolved from.xcresult_legacy.rsgets ~100 lines smaller.Verification
No behaviour change: the sources are offered in the order the chain tried them and the first is taken. All 11 pre-existing integration tests pass unchanged, plus 10 new unit tests covering normalization, candidate ordering and provenance, the stack-frame filter, and document-location cleaning.
🤖 Generated with Claude Code