Open stouset opened 2 years ago
Using #[cfg]
instead of cfg!
will work as you expect (it is also consistent with how the compiler evaluates the code). For example:
Appling the same behavior to cfg!
is not always good, considering that coverages generated under different test conditions can be merged. -- For now, I think it is reasonable to leave it up to the way the compiler evaluates the code for #[cfg]
and cfg!
.
I tried to merge two runs using the cfg
flag on and off, and the coverage report would only ever show one or the other was hit. I followed the instructions pretty closely. This may be buggy.
Unfortunately while #[cfg(…)]
works in the general case, it can also cause a ton of warnings as the Rust compiler no longer sees the other branch so might not see mut
variables being mutated, imported modules being used, etc.
I don't have a minimal test-case for the first paragraph above yet. I'm neck-deep in some stuff, will try to get you one.
I have some code that's gated by an
Given that only one of these branches can be hit statically, I'd appreciate being able to disable coverage for the lines that are excluded. Not sure how possible this is.