2023-04-12 19:55:57 +02:00
|
|
|
# Music Hoard
|
|
|
|
|
|
|
|
## Code Coverage
|
|
|
|
|
|
|
|
### Pre-requisites
|
|
|
|
|
|
|
|
``` sh
|
|
|
|
rustup component add llvm-tools-preview
|
|
|
|
cargo install grcov
|
|
|
|
```
|
|
|
|
|
|
|
|
### Generating Code Coverage
|
|
|
|
|
|
|
|
```sh
|
2023-04-13 14:09:59 +02:00
|
|
|
env CARGO_TARGET_DIR=codecov \
|
|
|
|
cargo clean
|
2023-04-12 19:55:57 +02:00
|
|
|
env RUSTFLAGS="-C instrument-coverage" \
|
2023-04-13 14:09:59 +02:00
|
|
|
LLVM_PROFILE_FILE="codecov/debug/profraw/musichoard-%p-%m.profraw" \
|
|
|
|
CARGO_TARGET_DIR=codecov \
|
2023-04-27 20:09:45 +02:00
|
|
|
cargo test --all-features
|
2023-04-13 14:09:59 +02:00
|
|
|
grcov codecov/debug/profraw \
|
|
|
|
--binary-path ./codecov/debug/ \
|
2023-04-12 19:55:57 +02:00
|
|
|
--output-types html \
|
|
|
|
--source-dir . \
|
|
|
|
--ignore-not-existing \
|
|
|
|
--ignore "tests/*" \
|
|
|
|
--ignore "src/main.rs" \
|
2023-04-13 14:09:59 +02:00
|
|
|
--excl-start "mod tests \{|GRCOV_EXCL_START" \
|
|
|
|
--excl-stop "GRCOV_EXCL_STOP" \
|
|
|
|
--output-path ./codecov/debug/coverage/
|
|
|
|
xdg-open codecov/debug/coverage/index.html
|
2023-04-12 19:55:57 +02:00
|
|
|
```
|
|
|
|
|
2023-04-13 14:09:59 +02:00
|
|
|
Note that some changes may not be visible until `codecov/debug/coverage` is removed and the `grcov`
|
2023-04-12 19:55:57 +02:00
|
|
|
command is rerun.
|
2023-04-13 14:09:59 +02:00
|
|
|
|
|
|
|
For most cases `cargo clean` can be replaced with `rm -rf ./codecov/debug/{coverage,profraw}`.
|