-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
calculate-coverage.sh
47 lines (41 loc) · 1.2 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
45
46
47
#!/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 -Cinline-threshold=0 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS=$RUSTFLAGS
# build the test binary with coverage instrumentation
executables=($(cargo test --workspace --tests --no-run --all-features --message-format=json | jq -r "select(.profile.test == true) | .executable"))
# run instrumented tests
for e in "${executables[@]}"
do
$e
done
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