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
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
--coverage-diff <base-ref>(defaultorigin/HEADwhen omitted) restricting the report to lines added or modified against that ref.git diff --unified=0 <base>...HEADgives the changed line ranges per file; intersect those with the lines already classified as executable.BASHUNIT_COVERAGE_MIN) means in diff mode: most likely a separate minimum for changed lines, since the two numbers answer different questions.Constraints
gitis not currently a hard runtime dependency of a coverage run; it would become one for this mode only, so the absence ofgitor of a repository must degrade with a clear message, not a stack of errors.git diffper run is fine.Acceptance criteria
tests/acceptance/bashunit_coverage_forks_test.shstill passes)make sa·make lint·./bashunit --parallel --simple --strict tests/·bash build.sh bin -v