-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grcov doesn't work with proc macros #494
Comments
@zbraniecki I assume you have |
I did, and had to remove them to make the grcov work with proc macros. |
Faced similar issue and after suggestion rust-lang/rust#78011 following has worked for me: Extending my workspace's
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. |
Proc-macros and `-Cpanic=abort` is not compatible (see mozilla/grcov#494)
Running into the same problems, too. Had to use |
In unicode-org/icu4x#331 we faced an issue where grcov failed because we have a proc macro crate.
It shows as:
The text was updated successfully, but these errors were encountered: