CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

trysac/diff-coverage

Measure test coverage of only the lines a change adds, by joining a unified diff with a Cobertura XML or coverage.py JSON report. Use when asked for diff coverage, patch coverage, or whether the new lines of a PR are tested.

Quality

95%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

how-it-works.mdreferences/

How diff coverage is computed

Inputs

  • Unified diff, up to 10 MiB. Added lines are collected per new-side path with their new-side line numbers. The a/ and b/ prefixes are stripped, \ No newline at end of file is ignored and CRLF is tolerated. Files whose new path is /dev/null are skipped.
  • Coverage report, up to 50 MiB, Cobertura XML or coverage.py JSON.
    • Cobertura: every class element's filename and its lines/line entries (number, hits). Backslashes become / and leading ./ is removed. If several classes list the same line, it is covered when any has hits > 0.
    • coverage.py JSON: files.<path>.executed_lines are covered and files.<path>.missing_lines are not.

Path matching

A diff path matches a coverage path when they are equal, when the diff path ends with / plus the coverage path, or when the coverage path ends with / plus the diff path. The longest matching coverage path wins. Two different paths of equal length that both match stop the run with ambiguous_path. A diff path with no match is listed as unmeasured and does not count toward the percentage.

Percentage

percent = covered changed lines * 100 / executable changed lines   (rounded half up, 1 decimal)

A changed line is executable when the coverage report has an entry for it. --fail-under passes when percent >= threshold; if there are no executable changed lines the run passes.

Output

  • text: one line per file, path covered/executable [missing ranges], then Diff coverage: NN.N%.
  • markdown: ## Diff coverage: NN.N% and a File | Covered | Missing lines table.
  • json: files, percent (string or null), passed and unmeasured_files.

Errors (exit code 2)

CodeCause
input_too_largeDiff over 10 MiB or report over 50 MiB.
invalid_diffA hunk header is malformed.
unsafe_xmlThe XML contains <!DOCTYPE or <!ENTITY.
invalid_reportMalformed XML or JSON, missing files, or an unrecognised format.
ambiguous_pathTwo coverage paths of equal length match one diff path.

references

SKILL.md

tile.json