Skip to content

feat(coverage): diff coverage — restrict the report to lines changed against a base ref #1032

Description

@Chemaclass

Split out of #1005, which scoped it as "the single biggest DX win available, and it is independent of the perf work". The perf half shipped in #1031; this is the remaining half, kept separate because it shares no code with it.

Problem

The coverage report is whole-file. For a PR the useful question is "are the lines I touched covered?", and answering it today means reading a full report and doing the diff by eye.

Whole-file percentages also move for reasons unrelated to the change under review: adding a well-covered file raises the total while saying nothing about the new code, and the reverse hides genuinely untested additions behind a healthy-looking number.

Sketch

  • A flag along the lines of --coverage-diff <base-ref> (default origin/HEAD when omitted) restricting the report to lines added or modified against that ref.
  • Reuse the existing hit data and the executable-line classifier — no engine work needed. git diff --unified=0 <base>...HEAD gives the changed line ranges per file; intersect those with the lines already classified as executable.
  • Decide what the threshold gate (BASHUNIT_COVERAGE_MIN) means in diff mode: most likely a separate minimum for changed lines, since the two numbers answer different questions.
  • Decide the behaviour when the base ref is unreachable (shallow clone in CI is the common case) — fail loudly rather than silently reporting whole-file numbers.

Constraints

Acceptance criteria

  • Changed-line coverage is reportable against a configurable base ref
  • A missing/unreachable base ref, a shallow clone, and a non-repository each produce a clear error rather than a misleading report
  • Threshold behaviour in diff mode is documented and tested
  • No per-line fork is reintroduced (tests/acceptance/bashunit_coverage_forks_test.sh still passes)
  • make sa · make lint · ./bashunit --parallel --simple --strict tests/ · bash build.sh bin -v

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions