-
Notifications
You must be signed in to change notification settings - Fork 40
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
Coverage reporting missing for binaries under-test #9
Comments
See also the discussion at assert-rs/assert_cli#104 |
I'm exactly in this situation right now, and unfortunately, I have no idea how to fix it. |
I've been able to get kcov to report something by calling kcov instead of calling directly my program. I activate it with the cargo test --features kcov -- --test-threads 1 It would be nice to have something similar natively, for example with an environment variable that allow the developer to set a wrapper — in that case, kcov. Something like RUST_ASSERT_CMD_WRAPPER="kcov --include-pattern=/src --exclude-pattern=/.cargo $PWD/cov" cargo test -- --test-threads 1 |
A wrapper sounds like a great way to resolve this since the coverage tools don't follow |
I'm assuming I'll need to use |
I’ll add that this would be a very nice feature. I’m currently using assert_cmd and tarpaulin and just like others have noted that this combination doesn’t work. |
grcov (and kcov) appears to work with assert_cmd. Other tools failed to mark lines as tested as others have mentioned here. |
My project doesn't use
|
Is there any plan on having this solved? Like @maxcountryman , I've seen that it doesn't work with tarpaulin coverage reports. |
I already had tests that should have a bigger coverage than reported. Apparently there is an [issue with assert_cmd](assert-rs/assert_cmd#9) that makes it not show coverage correctly for tarpaulin. So the workaround is to test as needed with assert_cmd and in the same function call one that re-runs the command executing run_app and only checks that the result is ok.
Sorry for the delay (Texas storm and life). I am not actively working on this but would welcome contributions from others. |
@brandonkal I've been unable to get grcov to recognize code coverage from assert_cmd. Are you positive that it did work? Was there something special you did? |
I am currently able to get both cargo-llvm-cov and grcov to recognize coverage of crate binaries tested with export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-Cinstrument-coverage"
cargo build
export LLVM_PROFILE_FILE="target/coverage/prof/%p-%m.profraw"
cargo test --all-features
grcov \
--source-dir . \
--binary-path target/debug \
--branch \
--excl-start 'mod tests \{' \
--ignore 'tests/*' \
-t html \
-o target/coverage/html \
target/coverage/prof An example repository where you can see coverage working: https://github.com/jwodder/ghrepo-rust |
For those that stumble across this issue because they can't find a solution on how to get cargo-llvm-cov to work: I got it working by using the command from above ( |
@mssun
From https://github.com/rust-lang-nursery/cli-wg/issues/9#issuecomment-385487756
The text was updated successfully, but these errors were encountered: