Skip to content

Commit

Permalink
build: add "coverage" profile to cargo
Browse files Browse the repository at this point in the history
Cargo doesn't fully pay attention to the RUSTFLAGS variable.
As such, to pass appropriate flags to rustc, Cargo uses a profile.
We thus create a profile specifically for generating code coverage and
updating the code coverage docs accordingly.

See rust-lang/rust#78011.

Closes #3553.
  • Loading branch information
Overflow0xFFFF authored and mergify[bot] committed Oct 7, 2022
1 parent 847858a commit 8b61f46
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@ members = [
]

exclude = ["implementations/rust/ockam/ockam_examples/example_projects"]

# Coverage profile for generating code coverage with grcov.
#
# See https://github.com/rust-lang/rust/issues/78011.
#
[profile.coverage]
panic = "abort"
opt-level = 0
overflow-checks = false
incremental = false
codegen-units = 1
inherits = "test"

2 changes: 1 addition & 1 deletion implementations/rust/DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Get a code coverage report:
```
cargo +nightly install grcov
env CARGO_INCREMENTAL=0 RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort --cfg tokio_unstable" RUSTDOCFLAGS="-Cpanic=abort" cargo +nightly test
env CARGO_INCREMENTAL=0 RUSTFLAGS="-Zprofile -Clink-dead-code --cfg tokio_unstable" cargo +nightly test --profile coverage
grcov --llvm . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
Expand Down

0 comments on commit 8b61f46

Please sign in to comment.