Find test coverage gaps in the current diff.
- Get the diff: run
git diff. If it is empty, rungit diff HEAD~1instead and note that the last commit was used instead of uncommitted changes. - Locate a coverage report:
- If
$1is given, use it as the path to the coverage report. - Otherwise, Glob for these common locations, in order:
coverage/lcov.info,coverage/coverage-final.json,coverage.xml,.coverage,coverage/clover.xml. - If none are found, state plainly that no coverage report was found and stop. Do not guess or fabricate coverage data.
- If
- Parse the diff to determine, per changed file, which line numbers were added or modified. Ignore purely deleted lines.
- Read and parse the coverage report according to its format:
- lcov (
lcov.info):SF:marks the start of a file section;DA:<line>,<hits>gives hit counts; a hit count of 0 means uncovered. - Cobertura (
coverage.xml):<class filename=...>contains<line number="N" hits="H"/>entries;hits="0"means uncovered. - Istanbul JSON (
coverage-final.json): each file entry hasstatementMap/s(or line-level data) mapping statement/line ids to hit counts; 0 means uncovered. - Clover (
clover.xml):<line num="N" count="C" .../>;count="0"means uncovered. .coverage(Python sqlite/binary): if it cannot be parsed directly, state that and skip it rather than guessing.
- lcov (
- Cross-reference: for each changed file that appears in the coverage report, find which of its changed line numbers have zero hits.
- Output a compact report, one section per file:
- File path
- List of uncovered changed line numbers (collapse consecutive runs into ranges, e.g.
12-15, 22, 40-41) - If a changed file has no entry at all in the coverage report, list it separately under "Not covered by any test run" instead of guessing at its status.
Keep output terse and factual. Do not speculate about why a line is uncovered or suggest fixes unless asked.