blob: 9e61bc754c74899f6a2afb488887224f43af419a (
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
44
45
46
47
48
49
50
|
#!/bin/sh
set -eu
mkdir -p public
call_grcov() {
output_type=$1
output_path=$2
# Explanation of the options below:
# grcov coverage-profiles _build - paths where to find .rawprof (llvm) and .gcda (gcc) files, respectively
# --binary-path ./_build/target/debug/ - where the Rust test binaries are located
# --source-dir . - toplevel source directory
# --branch - compute branch coverage if possible
# --ignore '**/build/markup5ever*' - ignore generated code from dependencies
# --ignore '**/build/cssparser*' - ignore generated code from dependencies
# --ignore 'cargo_cache/*' - ignore code from dependencies
# --excl-line 'unreachable!' - ignore lines with the unreachable!() macro
# --output-type $output_type
# --output-path $output_path
grcov coverage-profiles _build \
--binary-path ./_build/target/debug/ \
--source-dir . \
--branch \
--ignore '**/build/markup5ever*' \
--ignore '**/build/cssparser*' \
--ignore 'cargo_cache/*' \
--excl-line 'unreachable!' \
--output-type $output_type \
--output-path $output_path
}
call_grcov html public/coverage
# Disable the cobertura report for now; it is only used for showing coverage
# in the diff view of merge requests.
#
# After switching to gcov-based instrumentation (-Zprofile in .gitlab-ci.yml), this
# coverage.xml is almost 500 MB and causes gitlab's redis to OOM.
#
# call_grcov cobertura coverage.xml
# Print "Coverage: 42.42" so .gitlab-ci.yml will pick it up with a regex
#
# We scrape this from the HTML report, not the JSON summary, because coverage.json
# uses no decimal places, just something like "42%".
grep -Eo 'abbr title.* %' public/coverage/index.html | head -n 1 | grep -Eo '[0-9.]+ %' | grep -Eo '[0-9.]+' | awk '{ print "Coverage:", $1 }'
|