feat(coverage): map and document non-rust report paths - #2198
Merged
Merged
Conversation
Add explicit longest-prefix mappings so package and source-root report filenames join to git diffs. Apply mappings to head shards and the baseline before filters and source markers, preserving max-hit merges. Verify nyc, coverage.py, gcovr, coverlet and Dart reports against real git diffs. Document producer commands, mapping rules and limitations. Closes #2188
Treat an explicitly mapped absolute path as an accepted runner root, so unrelated SDK paths do not trigger a false workspace warning. Retain the empty-shard check and cover the mixed-path regression.
Keep the regression fixture out of the repository's source-marker scan, while generating the same malformed marker for the command test.
CoverageTotal: 97.95% ⚪ 0 pp vs Comparing
🔇 269 ignored region(s), 0 tolerated region(s)
Patch coveragePatch: 98.59% (210/213 new lines covered)
Uncovered new lines (3)
|
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.
Description
Coverage reports can have valid overall coverage while package-relative, source-root-relative or CI-runner filenames fail to join to git paths, leaving patch coverage empty. Add explicit
diff.path-mappingsincoverage.yamlso these filenames can be attributed to the diff. The longest directory-prefix match wins, paths are mapped once, and collisions retain the existing maximum-hit rule.Type of Change
Related Issue
Closes #2188
Implementation plan: #2188 (comment)
Changes Made
src/coverage/paths.rs: validated prefix replacements, Windows separator handling, source-root prepending and alias merging. Empty/missing mappings preserve existing behavior.src/cli/coverage/diff.rs: load mappings through existing config discovery and apply them to each head shard and the baseline before prefix stripping, exclusions and source markers. Honor mapped runner roots in shard diagnostics.tests/fixtures/coverage/non-rust/: genuine nyc, coverage.py, gcovr, coverlet and Dart reports with producer versions or pinned upstream provenance. End-to-end tests demonstrate an empty patch before mapping and the expected covered/uncovered totals after mapping. Additional tests cover native JaCoCo, baseline symmetry, filters, markers, invalid destinations, boundaries and collisions.docs/coverage.md: path pipeline audit, mapping examples and producer commands for JS/TS, Python, C/C++, Swift, Ruby, PHP, .NET, Dart, Scala, Go and Java/Kotlin. Update the config inventory and Unreleased changelog.Testing
Run from the worktree root, with
$WTset to that root and Cargo commands explicitly targeting its manifest:All commands passed. Both full Rust suites were rerun after rebase; the final test-only marker-fixture cleanup was then verified with its focused regression test, marker lint and both Clippy configurations. The snapshot run passed 64 integration tests with no drift. The Python checker suite passed (90 tests, one skipped).
cargo docsucceeded with 173 warnings in unchanged files; no new documentation warning locations are in this diff. The changelog check passed over all three commits.New-code coverage percentage was not measured. Regression tests exercise real git attribution; the suite does not require every language toolchain. nyc 18.0.0, coverage.py 7.16.2 and Dart SDK 3.13.5/package:coverage 1.15.1 were run locally. gcovr and coverlet fixtures are upstream captures; other producer commands were checked against primary documentation, rather than executed locally. Windows report paths are unit-tested; no native Windows build was run here.
Review Focus Areas
Mapping order, longest component-boundary matching, head/baseline symmetry, and the documented limitation for modules with indistinguishable filenames.
Checklist
Additional Notes
The review found one false workspace warning for a shard containing both a mapped CI path and an unrelated SDK path (src/cli/coverage/diff.rs:610). A regression test reproduced it; a follow-up commit fixes it. Final validation also caught the deliberately malformed marker fixture as a literal in Rust source. A test-only follow-up constructs the same text at runtime so the repository marker guard passes. No findings were skipped.
No material departure from the plan. Go coverprofile and JaCoCo parsers have already landed, so their native formats are documented rather than obsolete converter requirements. Mapping is explicit:
coverage mergedoes not consume diff-specific config, Cobertura<sources>are not guessed, and unrelated modules emitting identical filenames must be distinguished before combination. No unrelated follow-ups were found.No breaking changes, extension changes or deployment steps.