forked from tari-project/bulletproofs-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_coverage.sh
executable file
·66 lines (57 loc) · 1.94 KB
/
test_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Prerequisites
# 1. You need LLVM-COV tools:
# $ rustup component add llvm-tools-preview
# 2. and Rust wrappers for llvm-cov:
# $ cargo install cargo-binutils
# 3. The rust name demangler
# $ cargo install rustfilt
# 4. jq
# 5. genhtml
# $ sudo apt install lcov
RUSTFLAGS="-C instrument-coverage"
LLVM_PROFILE_FILE="./cov_raw/bulletproofs-plus-%m.profraw"
get_binaries() {
files=$( RUSTFLAGS=$RUSTFLAGS cargo +nightly test --tests --no-run --message-format=json \
| jq -r "select(.profile.test == true) | .filenames[]" \
| grep -v dSYM - \
);
files=("${files[@]/#/-object }")
}
get_binaries
# Remove old coverage files
rm cov_raw/*profraw cov_raw/bulletproofs-plus.profdata cov_raw/bulletproofs-plus.lcov cov_raw/bulletproofs-plus.txt
RUSTFLAGS=$RUSTFLAGS LLVM_PROFILE_FILE=$LLVM_PROFILE_FILE cargo +nightly test --tests
cargo +nightly profdata -- \
merge -sparse ./cov_raw/bulletproofs-plus-*.profraw -o ./cov_raw/bulletproofs-plus.profdata
cargo +nightly cov -- \
export \
--Xdemangler=rustfilt \
--format=lcov \
--show-branch-summary \
--show-instantiation-summary \
--show-region-summary \
--ignore-filename-regex='/.cargo/registry' \
--ignore-filename-regex="^/rustc" \
--ignore-filename-regex="curve25519-dalek" \
--instr-profile=cov_raw/bulletproofs-plus.profdata \
$files \
> cov_raw/bulletproofs-plus.lcov
cargo +nightly cov -- \
show \
--Xdemangler=rustfilt \
--show-branch-summary \
--show-instantiation-summary \
--show-region-summary \
--ignore-filename-regex='/.cargo/registry' \
--ignore-filename-regex="^/rustc" \
--ignore-filename-regex="curve25519-dalek" \
--instr-profile=cov_raw/bulletproofs-plus.profdata \
$files \
> cov_raw/bulletproofs-plus.txt
if [ -z ${SKIP_HTML+x} ]; then
genhtml -o coverage_report cov_raw/bulletproofs-plus.lcov
else
echo "Skipping html generation"
fi
# open coverage_report/src/index.html