You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
first of all, thanks for the great work on cargo-llvm-cov.
I noticed that the branch coverage report is not consistent across different output formats.
I am aware that branch coverage is still unstable and relies on nightly rustc,
but I couldn't find an issue for this specific problem.
Hence, I am opening this issue to discuss the observed behaviour
and to provide a minimal example to reproduce the issue.
Given the following Rust code:
pubfnmaybe_increment_by<T>(mutvalue:T,increment:Option<T>) -> TwhereT: std::ops::AddAssign + Copy,{ifletSome(increment) = increment {
value += increment;}
value
}#[test]#[cfg(test)]fntest_maybe_increment_by(){assert_eq!(maybe_increment_by::<u32>(1, Some(2)), 3);}
The expected behaviour is that the branch coverage is 50% or 1/2,
because the test currently does not account for the branch where increment is None.
All output formats seem to show the correct branch coverage.
However, if I change the test case to cover the None case like this:
You could argue that the expected branch coverage should be 100% or 2/2.
Some formats, like --html or the standard report format show the expected branch coverage:
Other formats, like --cobertura or --lcov show a different branch coverage of 75% or 3/4.
The 3/4 branches are most likely reported due to Rust's monomorphization and the different
types used for the generic function maybe_increment_by.
Now I am wondering if this is a bug or intended behaviour.
If it is the latter, sorry for the noise and thanks in advance for the clarification.
The text was updated successfully, but these errors were encountered:
👋 Hi,
first of all, thanks for the great work on
cargo-llvm-cov
.I noticed that the branch coverage report is not consistent across different output formats.
I am aware that branch coverage is still unstable and relies on nightly rustc,
but I couldn't find an issue for this specific problem.
Hence, I am opening this issue to discuss the observed behaviour
and to provide a minimal example to reproduce the issue.
Given the following Rust code:
The expected behaviour is that the branch coverage is
50%
or1/2
,because the test currently does not account for the branch where
increment
isNone
.All output formats seem to show the correct branch coverage.
However, if I change the test case to cover the
None
case like this:You could argue that the expected branch coverage should be
100%
or2/2
.Some formats, like
--html
or the standard report format show the expected branch coverage:Other formats, like
--cobertura
or--lcov
show a different branch coverage of75%
or3/4
.The
3/4
branches are most likely reported due to Rust's monomorphization and the differenttypes used for the generic function
maybe_increment_by
.Now I am wondering if this is a bug or intended behaviour.
If it is the latter, sorry for the noise and thanks in advance for the clarification.
The text was updated successfully, but these errors were encountered: