OpenTally/coverage.sh

25 lines
1.1 KiB
Bash
Raw Normal View History

2021-06-12 07:37:41 +02:00
#!/bin/bash
2021-10-25 15:55:04 +02:00
PATH=$PATH:$HOME/.cargo/bin
2021-06-12 07:37:41 +02:00
mkdir -p target/coverage/prof
rm target/coverage/prof/*.profraw
2022-08-20 23:31:32 +02:00
export RUSTFLAGS="-Cinstrument-coverage -Copt-level=0 -Clink-dead-code"
2021-06-12 07:37:41 +02:00
export LLVM_PROFILE_FILE="target/coverage/prof/opentally-%p-%m.profraw"
export CARGO_TARGET_DIR=target/coverage
cargo test
llvm-profdata merge -sparse target/coverage/prof/*.profraw -o target/coverage/opentally.profdata
2021-09-13 18:23:51 +02:00
for file in $(cargo test --no-run --message-format=json 2>/dev/null | jq -r "select(.profile.test == true) | .filenames[]"); do echo -n --object '"'$file'" '; done > target/coverage/objects
# Need "eval" to correctly parse arguments
2021-10-25 15:55:04 +02:00
eval llvm-cov show target/coverage/debug/opentally -instr-profile=target/coverage/opentally.profdata -Xdemangler=rustfilt \
2021-09-13 18:23:51 +02:00
$(cat target/coverage/objects) \
2021-10-25 15:55:04 +02:00
-ignore-filename-regex="/\\\\." \
-ignore-filename-regex="^/rustc" \
-ignore-filename-regex="src/numbers/rational_num.rs" \
-ignore-filename-regex="src/stv/gregory/prettytable_html.rs" \
-ignore-filename-regex="src/stv/wasm.rs" \
-ignore-filename-regex="tests/" \
-format=html --show-instantiations=false --output-dir=target/coverage/html