Expand description
Patch (changed-line) coverage (Python — #132, parent #46).
Enforces the README Coverage rule’s changed-line guarantee: every line a diff
touches must be covered by the unit suite. Where crate::coverage measures
the whole suite against a floor (#26) and the #131 ratchet against a
baseline, this measures only the lines <base>...HEAD added or modified —
failing when any changed, executable line is left uncovered.
Two inputs are combined:
- the diff —
changed_linesrunsgit diff --unified=0 <base>...HEADand returns the new-side line numbers each file gained. This is the diff machinery established here, shared by the forthcoming TypeScript / Rust twins. - the coverage — coverage.py’s per-file
missing_lines/missing_branches(crate::coverage::measure_patch_report). A changed line is uncovered when it is a missing line, or the source of a branch the suite never took (uncovered_changed_lines). Non-executable changed lines (comments, blanks) andcoverage-exempt files have nothing to cover and are skipped.
Relationship to the commit-scoped co-change rule (crate::co_change, #33):
co-change enforces that a changed source and its colocated test move
together; patch coverage enforces that the changed lines are actually
exercised. They are complementary, not overlapping — co-change can pass (the
test file changed) while patch coverage fails (the change isn’t covered), and
vice versa.
Structs§
- Uncovered
- A changed source line the unit suite doesn’t cover — a
root-relative path and the 1-based new-side line number.
Functions§
- changed_
lines - The new-side lines each file gained in
repo’s<base>...HEADdiff, keyed byrepo-relative path. The diff machinery shared by the TS / Rust twins. - check
- Every line added or modified in
root’s<base>...HEADdiff that the unit suite doesn’t cover, sorted for deterministic output.omitis thecoverage-rule exemptions (as incrate::coverage::measure) — an exempt file is omitted from the run, so its changed lines are lifted. - uncovered_
changed_ lines - Pure: every changed line the coverage report marks uncovered — a
missing_line, or the source of amissing_branch(a branch out of the line the suite never took). A changed file absent fromfileswas not measured (a test file, or acoverage-exempt file omitted from the run) and contributes nothing; a changed line that is neither missing nor a branch source (a comment or blank) has nothing to cover.filesis keyed byroot-relative path, aschangedis.