fix(coverage): don't panic in summary reporter without a common root#35211
Merged
Conversation
When coverage reports can't be reduced to a common file-system root (e.g. on Windows when coverage spans multiple drive letters such as a C:\…\Temp test file and a D:\…\workspace file), collect_summary returns an empty map. The summary reporter then called .unwrap() on the missing "" root entry and panicked. Bail out of the summary table when there is no root entry, and avoid a second panic on the empty .max() call. Fixes #30924
Member
ReviewTraced the full path in Correctness
Test coverage
Suggestions (all minor, non-blocking)
VerdictLGTM. Small, correctly-targeted, well-explained panic fix with a genuine regression test. Only asks are a clarifying comment on the (unreachable) second guard and ideally a user-facing message instead of silent no-output — neither blocking. |
Address review feedback: - Emit a log::warn! explaining why no summary table is printed when the reports span multiple file-system roots, instead of silently producing no output. - Document that the adjacent .unwrap_or(0) is defense-in-depth and that entries is always non-empty once the "" root entry is present.
Member
|
Pushed 3644e5d addressing the two review nits:
|
bartlomieju
enabled auto-merge (squash)
June 14, 2026 10:31
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
Fixes the panic reported in #30924, which still reproduces on Deno 2.7.7 (and on
main):SummaryCoverageReporter::donecalledsummary.get("").unwrap()on the result ofcollect_summary.collect_summaryreturns an empty map (without the""root entry) whenever the file reports can't be reduced to a common file-system root — i.e. whenfind_root(...).and_then(|r| r.to_file_path().ok())yieldsNone.On Windows this happens when coverage spans multiple drive letters: the temp test files live under
C:\Users\RUNNER~1\AppData\Local\Temp\while the workspace is onD:\.... The character-wise common prefix collapses tofile:///, which has no drive letter, soto_file_path()fails,collect_summaryreturns an empty map, and the reporter panics. This matches the panic URLs andD:\a\...\cov\...paths in the issue, and explains why it only reproduces on Windows.(The simpler "all source files were skipped → empty
file_reports" case is already handled gracefully upstream incover_files, which returnsNo covered files included in the report.)Changes
""root entry instead of unwrapping..max().unwrap()on the entries list (would panic on an empty list) with.unwrap_or(0).donewith reports that have no common file-system root and asserts it doesn't panic. The test fails before this change and passes after.Test plan
cargo test -p deno --lib summary_reporter_does_not_panic— passes with the fix, panics without it.cargo clippy -p deno --lib— clean.rustfmt— no changes.Fixes #30924
https://claude.ai/code/session_01L957ioUbJpxDa8Sv9yCtEq
Generated by Claude Code