fix: don't panic when a source file disappears during diagnostic rendering#665
Closed
MatthewMckee4 wants to merge 1 commit intomainfrom
Closed
fix: don't panic when a source file disappears during diagnostic rendering#665MatthewMckee4 wants to merge 1 commit intomainfrom
MatthewMckee4 wants to merge 1 commit intomainfrom
Conversation
Merging this PR will not alter performance
|
…ering `utils::source_file` called `read_to_string(path).expect(...)` on the diagnostic rendering path. If a test file disappears between discovery and diagnostic rendering, the runner now returns an empty-bodied `SourceFile` rather than crashing.
f3db211 to
dc023ed
Compare
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.
Summary
utils::source_fileis called from the diagnostic rendering path whenever weneed to attribute a span back to a test file on disk. It used to read the file
with
.expect(\"Failed to read source file\"), which races against test filesbeing moved or deleted between discovery and diagnostic rendering and tears down
the entire worker process:
It now falls back to an empty-bodied
SourceFileviaunwrap_or_default()—the filename is still shown in diagnostics, but spans that reference the missing
file render as empty instead of crashing the run. A unit test exercises the
non-existent-path branch so the function is guaranteed not to panic on a missing
file.
This PR originally also tried to defuse two
.expect(\"builtin fixtures to not fail\")panics inpackage_runner::run_fixture. Those sites were removedentirely by #645, which rewrote built-in fixtures to run as pure Python, so
there is no longer a "this fixture has no AST" case at the Rust layer. The
rebase onto post-#645 main dropped those changes.
Test Plan
just test(818 tests passing)uvx prek run -a