contrib: add coverage-diff script
commit783faedd651356663678529109c726bc94d854c0
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 8 Oct 2018 14:52:09 +0000 (8 07:52 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Oct 2018 01:11:35 +0000 (10 10:11 +0900)
tree00cf35da634381fa306a3101e1c91e38fc6436ae
parent1d4361b0f344188ab5eec6dcea01f61a3a3a1670
contrib: add coverage-diff script

We have coverage targets in our Makefile for using gcov to display line
coverage based on our test suite. The way I like to do it is to run:

    make coverage-test
    make coverage-report

This leaves the repo in a state where every X.c file that was covered has
an X.c.gcov file containing the coverage counts for every line, and "#####"
at every uncovered line.

There have been a few bugs in recent patches what would have been caught
if the test suite covered those blocks (including a few of mine). I want
to work towards a "sensible" amount of coverage on new topics. In my opinion,
this means that any logic should be covered, but the 'die()' blocks covering
very unlikely (or near-impossible) situations may not warrant coverage.

It is important to not measure the coverage of the codebase by what old code
is not covered. To help, I created the 'contrib/coverage-diff.sh' script.
After creating the coverage statistics at a version (say, 'topic') you can
then run

    contrib/coverage-diff.sh base topic

to see the lines added between 'base' and 'topic' that are not covered by the
test suite. The output uses 'git blame -s' format so you can find the commits
responsible and view the line numbers for quick access to the context, but
trims leading tabs in the file contents to reduce output width.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/coverage-diff.sh [new file with mode: 0755]