Skip to content
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

Test coverage setup with grcov not working #2

Open
cdbrkfxrpt opened this issue Dec 15, 2020 · 2 comments
Open

Test coverage setup with grcov not working #2

cdbrkfxrpt opened this issue Dec 15, 2020 · 2 comments

Comments

@cdbrkfxrpt
Copy link

Hi,

I really like this crate, awesome work. I would love to deploy it in all our projects.

However, we use grcov in our toolchain and grcov requires the following environment to be set up:

export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Cpanic=abort"

The -Cpanic=abort flag means that tests are aborted why they panic, and the only way to avoid this is the #[should_panic] attribute. Which is very sad, since (as we probably agree) the #[should_panic] attribute is not really a very elegant way of testing for panics; cool_asserts::assert_panics is.

Would you see it possible somehow to make cool_asserts play nice with grcov? Is that even in scope, or do you see the responsibility for this in the hands of the grcov project?

Cheers, and thanks again for cool_asserts.

@Lucretiel
Copy link
Owner

Thanks for the report!

I'll see if I can think of anything, but my guess is that what you're asking for isn't possible, since there isn't going to be a way to get around the fact that assert_panics requires unwinding to recover the error. It appears that panic_abort_tests is related in some way to rust-lang/rust#32512, which calls for spawning tests in separate processes, so that they can be recovered in the event of a crash. I'm not sure that it's possible for assert_panics to work in the same way.

It seems as though the lack of panic support is a known issue in grcov, and I'm inclined to think it's on their side that the issue needs to be fixed. I'll leave this issue open for now as a known issue, and close it if it gets resolved on their end, or if a solution presents itself for fixing it here.

@cdbrkfxrpt
Copy link
Author

Yeah, I figured that this is an issue with grcov; just thought maybe it's feasible on this end and knocking on what I perceive to be a much bigger and therefore likely more static project can be foregone.

I hope they fix it. I really like this crate and we'd have plenty of use for it but I rely on test coverage as a metric. Welp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants