Created
April 23, 2021 22:50
-
-
Save hn3000/80b4b2e72ac15272f0db0cf09f29fc52 to your computer and use it in GitHub Desktop.
rust test coverage with grcov
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
METHOD=${1:-${METHOD:-"A"}} | |
if [ "$METHOD" == "A" ] | |
then | |
export CARGO_INCREMENTAL=0 | |
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" | |
export RUSTDOCFLAGS="-Cpanic=abort" | |
unset LLVM_PROFILE_FILE | |
else | |
export CARGO_INCREMENTAL=0 | |
export RUSTFLAGS="-Zinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" | |
export RUSTDOCFLAGS="-Cpanic=abort" | |
export LLVM_PROFILE_FILE="your_name-%p-%m.profraw" | |
fi | |
cargo clean | |
cargo build | |
cargo test | |
grcov . -s . --binary-path ./target/debug/ -t html --excl-br-line 'assert' --excl-start '#(\[cfg\(test\)\]|\[test\])' --branch --ignore-not-existing --ignore test/ -o ./grcov-coverage/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment