-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculate-coverage.sh
executable file
·44 lines (38 loc) · 1.14 KB
/
calculate-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
#!/bin/bash
# set the destination for profile files
export LLVM_PROFILE_FILE="target/debug/coverage/%p-%m.profraw"
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zinstrument-coverage -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Cpanic=abort"
# build the test binary with coverage instrumentation
executables=$(cargo test --tests --no-run --all-features --message-format=json | jq -r "select(.profile.test == true) | .executable")
# run instrumented tests
$executables
if [[ "${CI}" ]]
then
echo "building coverage for ci"
./grcov . \
-s . \
--binary-path ./target/debug/ \
-t lcov \
--branch \
--ignore-not-existing \
-o ./target/debug/coverage/lcov.info
else
echo "building coverage for local"
grcov . \
-s . \
--binary-path ./target/debug/ \
-t lcov \
--branch \
--ignore-not-existing \
-o ./target/debug/coverage/lcov.info
grcov . \
-s . \
--binary-path ./target/debug/ \
-t html \
--branch \
--ignore-not-existing \
-o ./target/debug/coverage/html
open ./target/debug/coverage/html/index.html
fi