-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add instruction for using grcov to help improve unit test coverage
- Loading branch information
1 parent
51b4b53
commit ef6553a
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,5 @@ script.py | |
build/ | ||
dist/ | ||
|
||
# grcov | ||
*.profraw |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Getting test coverage report with grcov # | ||
|
||
Get [grcov](https://github.com/mozilla/grcov ) and install their requirements for your system. | ||
|
||
To get a complete test report run the following commands with these env | ||
variables set. (I found some flags they suggested broke with some of our packages.) | ||
|
||
`.bashrc` | ||
```shell | ||
export LLVM_PROFILE_FILE="your_name-%p-%m.profraw" | ||
export RUSTDOCFLAGS="-Cpanic=abort" | ||
``` | ||
|
||
1. `RUSTFLAGS="-Zinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off -Zpanic_abort_tests" CARGO_INCREMENTAL=0 RUSTC_BOOTSTRAP=1 cargo build` | ||
1. `RUSTFLAGS="-Zinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off -Zpanic_abort_tests" CARGO_INCREMENTAL=0 RUSTC_BOOTSTRAP=1 cargo test` | ||
1. `grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/` | ||
|
||
|
||
## Known issues ## | ||
|
||
- If you run `grcov` on Windows you will need to run it as admin or it will fail | ||
with an error related to symlinks. [Issue 561](https://github.com/mozilla/grcov/issues/561) | ||
- `[ERROR] Execution count overflow detected.` can occur when running `grcov` | ||
but is not fatal and a report will still be created. [Issue 613](https://github.com/mozilla/grcov/issues/613) |