Skip to content

Commit 8b61f46

Browse files
Overflow0xFFFFmergify[bot]
authored andcommitted
build: add "coverage" profile to cargo
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.
1 parent 847858a commit 8b61f46

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,16 @@ members = [
3232
]
3333

3434
exclude = ["implementations/rust/ockam/ockam_examples/example_projects"]
35+
36+
# Coverage profile for generating code coverage with grcov.
37+
#
38+
# See https://github.com/rust-lang/rust/issues/78011.
39+
#
40+
[profile.coverage]
41+
panic = "abort"
42+
opt-level = 0
43+
overflow-checks = false
44+
incremental = false
45+
codegen-units = 1
46+
inherits = "test"
47+

implementations/rust/DEVELOP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Get a code coverage report:
8383
```
8484
cargo +nightly install grcov
8585
86-
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
86+
env CARGO_INCREMENTAL=0 RUSTFLAGS="-Zprofile -Clink-dead-code --cfg tokio_unstable" cargo +nightly test --profile coverage
8787
8888
grcov --llvm . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
8989

0 commit comments

Comments
 (0)