aboutsummaryrefslogtreecommitdiff
path: root/scripts/gen_html_coverage.sh
blob: bb239fbf218a4fb62a35401d2decc21581445b99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
set -eu

# To filter only on c++ stuff:
# scripts/gen_html_coverage.sh -ext "*.cpp,*.hh"

SCRIPT_DIR=$(dirname "$0")
case $SCRIPT_DIR in
    "/"*)
        ;;
    ".")
        SCRIPT_DIR=$(pwd)
        ;;
    *)
        SCRIPT_DIR=$(pwd)/$(dirname "$0")
        ;;
esac

FILTER=""
if test $# -ge 1; then
    if test "$1" = "--help"; then
        echo "Usage: gen_html_coverage.sh [--help] [-ext \"ext1,...\"]"
        exit
    fi

    if test "$1" = "-ext"; then
        FILTER="$2"
        shift
        shift
    fi

    if test $# -ge 1; then
        echo "Invalid option: $1"
        echo "Usage: gen_html_coverage.sh [--help] [-ext \"ext1,...\"]"
        exit
    fi
fi

rm -rf coverage_html
lcov --directory src --directory include --capture --output-file proj.info
"$SCRIPT_DIR"/filter_lcov_info.py "$FILTER" < proj.info > proj.info.filtered
mv proj.info.filtered proj.info
genhtml -o ./coverage_html --ignore-errors source --num-spaces 2 proj.info