Description
I used grcov to measure the test coverage of the project, but the results didn't seem very good, both source-based and gcov-based.@richkadel
The source-based approach is shown here.
To test the rand project, perform the following steps:
rustup component add llvm-tools-preview
export RUSTFLAGS="-Zinstrument-coverage"
cargo build
export LLVM_PROFILE_FILE="your_name-%p-%m.profraw"
cargo test
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
In the rand
test result, for example, in the /rand/target/debug/coverage/rand_core/src/le.rs
file:
Q1: In this file, two similar functions, one is detected and the other is not found. I don't know why.
Only one function is shown here, and the other function seems odd that grcov did not find it.
Note: In the /rand/target/debug/coverage/rand_core/src/block.rs
file, a large number of codes are not covered. Judgment here seems to have failed.
...
Q2:In addition, the test function does not appear to be detected. In other files, the test function is executed.
Do not execute test code:/rand/target/debug/coverage/rand_core/src/os.rs
execute test code:/rand/target/debug/coverage/src/seq/mod.rs
Q3:Sometimes structs/enumerations are included in the row coverage, but sometimes they are not. What are the criteria for this?
rustc --version --verbose
:
rustc 1.58.0-nightly (29b124802 2021-10-25)
binary: rustc
commit-hash: 29b1248025b19bd132c8047fc710ea9314b9b76b
commit-date: 2021-10-25
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0