forked from solendprotocol/solana-program-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoverage.sh
executable file
·30 lines (22 loc) · 871 Bytes
/
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
#!/usr/bin/env bash
#
# Runs all program tests and builds a code coverage report
#
set -ex
cd "$(dirname "$0")"
if ! which grcov; then
echo "Error: grcov not found. Try |cargo install grcov|"
exit 1
fi
rm *.profraw || true
rm **/**/*.profraw || true
rm -r target/coverage || true
# run tests with instrumented binary
RUST_LOG="error" CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test --features test-bpf
# generate report
mkdir -p target/coverage/html
grcov . --binary-path ./target/debug/deps/ -s . -t html --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/html
grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov
# cleanup
rm *.profraw || true
rm **/**/*.profraw || true