Open zbraniecki opened 4 years ago
@zbraniecki I assume you have -Cpanic=abort -Zpanic_abort_tests
in RUSTFLAGS?
I did, and had to remove them to make the grcov work with proc macros.
Faced similar issue and after suggestion https://github.com/rust-lang/rust/issues/78011 following has worked for me:
Extending my workspace's Cargo.toml
has helped:
cargo-features = ["named-profiles"]
[profile.coverage]
panic = "abort"
opt-level = 0
overflow-checks = false
incremental = false
codegen-units = 1
inherits = "test"
Then I am able to collect code coverage metrics with a following command:
export RUSTFLAGS="-Zprofile"
cargo test -p $pkg --lib --all-features --profile=coverage -Z unstable-options
# and collect coverage metrics respectively
grcov ./target/coverage/ -s . -t lcov --llvm --branch --ignore-not-existing --ignore "cli*" --ignore "*test*" --ignore "target/*" --ignore "*migrations*" --excl-start '#\[cfg\(test\)\]' --excl-stop '^}' -o $coverage_report
Note: we have to comment out above lines in Cargo.toml when compiling on rust-stable.
We should mention this on the readme as proc-macros are not uncommon!
I think proc-macros are supported by source-based coverage, I've recently added support for it in grcov (version 0.6.0). Short explanation at https://marco-c.github.io/2020/11/24/rust-source-based-code-coverage.html, docs at https://github.com/mozilla/grcov#example-how-to-generate-source-based-coverage-for-a-rust-project, full example at https://github.com/marco-c/rust-code-coverage-sample.
Yeah, I know the code is called by the test, grcov flags the macro as having been called, but then the body of the function the macro is used on is listed as not called.
Running into the same problems, too. Had to use -Cpanic=unwind
. Is there another walk around?
In https://github.com/unicode-org/icu4x/pull/331 we faced an issue where grcov failed because we have a proc macro crate.
It shows as: