forked from aebruno/whisperfish
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
coverage.sh
executable file
·47 lines (38 loc) · 1.04 KB
/
coverage.sh
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
#!/bin/bash
# shellcheck disable=SC2155
set -e
if which llvm-profdata >/dev/null ; then
export LLVM_TOOL=$(which llvm-profdata)
else
echo "Error: llvm-profdata not found"
exit 1
fi
if ! which grcov >/dev/null ; then
echo "Error: grcov not found"
exit 1
fi
export LLVM_PATH=$(dirname "${LLVM_TOOL}")
export RUSTFLAGS="-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off"
export LLVM_PROFILE_FILE="whisperfish-%p-%m.profraw"
export CARGO_TARGET_DIR="coverage"
cargo test
mkdir -p coverage/html
echo "Running grcov, this takes a little while..."
grcov . \
--binary-path ./coverage/debug/deps/ \
--branch \
--ignore-not-existing \
--ignore '../*' \
--ignore "/*" \
--ignore "whisperfish/tests/*" \
--ignore 'target/*' \
--ignore 'coverage/*' \
--llvm-path "${LLVM_PATH}" \
--excl-start "#\[cfg\(test\)\]" \
-s . \
-t html \
-o coverage/html
find . -name "*.profraw" -delete
if [ -f "coverage/html/index.html" ]; then
echo "Coverage report available in $(realpath "coverage/html/index.html")"
fi