Description
If multiple derive macros are used, and one is covered and one is uncovered, the results shown in the llvm-cov
output will not match the output produced by json.get_uncovered_lines()
. While llvm-cov
considers the line to be uncovered, json.get_uncovered_lines()
considers the line to be covered. So even if there is a missing line, --show-missing-lines
will not show the affected line and --fail-uncovered-lines 0
will have no effect.
Here is a reproducer:
use strum::{Display, EnumIter};
#[derive(Display, EnumIter, Clone, Debug, PartialEq)]
pub enum Foo {
A = 0,
B = 1,
}
#[cfg(test)]
mod tests {
use strum::IntoEnumIterator;
use super::*;
#[test]
fn test_foo_serde() {
for foo in Foo::iter() {
assert_eq!(foo, foo.clone());
}
}
}
Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
src/lib.rs 9 2 77.78% 3 1 66.67% 6 1 83.33% 0 0 -
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL 9 2 77.78% 3 1 66.67% 6 1 83.33% 0 0 -
The function created by the strum::EnumIter
macro is tested, while the function created by the strum::Display
macro is not. llvm-cov
considers line 3 to be uncovered, but this line is considered to be covered by json.get_uncovered_lines()
. This issue is caused by the following code, which was added to fix #181:
Lines 268 to 270 in b7e5eb5
Unfortunately, I don't see a simple solution which wouldn't add a regression. Any ideas?
Using the JSON output for --fail-uncovered-lines
would already be an improvement, so that at least the exit code would be correct, even if some lines in --show-missing-lines
are missing. What do you think?