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 build-trust#3553.
  • Loading branch information
Overflow0xFFFF authored and akki1306 committed Oct 10, 2022
1 parent cffb903 commit 789ad74
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 789ad74

Please sign in to comment.