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

else lines are reported as not covered #235

Closed
matteomonti opened this issue May 31, 2019 · 6 comments
Closed

else lines are reported as not covered #235

matteomonti opened this issue May 31, 2019 · 6 comments

Comments

@matteomonti
Copy link

I just setup tarpaulin with Travis CI + Codecov to monitor the coverage of my project. I noticed that one file that I was confident I had thoroughly tested was reported to only have around 85% coverage.

Here is the code coverage report for that file:

https://codecov.io/gh/rainvg/drop/src/b5d608e6e74df069676d9f04134c3de07c58cf8d/src/data/varint.rs

Lines 29, 53, and 59 are reported as not covered, but the only content of those lines is

} else {

and both branches of the if clause they belong to are fully covered.

Am I missing something? Is it possible that I did something wrong with my configuration?

@swiftgist
Copy link

I have the same issue with a single else reporting not covered:

        if self.verbose {
            eprintln!("{} {}", path.to_string_lossy().to_string(), err);
        } else {
            if self.once {
                eprintln!("Use -v to see skipped files");
                self.once = false;
            }
        }

I do have another else that is reported as covered in this same source file. The only difference that I can speculate is that the missed else is only exercised in one path for each unit test. The covered else exercises both branches in a single unit test.

For my case, a unit test either sets the verbose option or doesn't. I did try to set, call, unset, call, but that did not change the coverage report.

This is tarpaulin 0.8.3

@shenek
Copy link

shenek commented Jun 24, 2019

I tried to reproduce it and it seem that when else occurs in a function inside impl block it is marked as not covered.

I made a small patch to update the current tests to fail.

diff --git a/tests/data/structs/src/lib.rs b/tests/data/structs/src/lib.rs
index 497b77f..9767819 100644
--- a/tests/data/structs/src/lib.rs
+++ b/tests/data/structs/src/lib.rs
@@ -15,6 +15,14 @@ impl Foo {
             z: None
         }
     }
+
+    fn is_even(x: u32) -> bool {
+        if x%2 == 0 {
+            true
+        } else {
+            false
+        }
+    }
 }
 
 #[test]
@@ -33,4 +41,7 @@ fn struct_exprs() {
         x: 5,
         ..Default::default()
     };
+
+    Foo::is_even(5);
+    Foo::is_even(6);
 }

@miehe-dup
Copy link

Can confirm the issue.

Until resolved, I created this python script to remove these false positives from cobertura.xml files: https://gist.github.com/miehe-dup/68c87099d485e5f8fb347dad6b1c15be

@CAD97
Copy link

CAD97 commented Aug 10, 2019

Can confirm with tarpaulin 0.8.5.

@rye
Copy link
Contributor

rye commented Aug 12, 2019

This has already been reported in #136.

@xd009642
Copy link
Owner

Yeah I'm going to close this as duplicated, anyone who's a wizz at disassembly who wants to take a look is more than welcome also 😄 I've only made slight progress with these sort of issues and a compiler update can sometimes change results significantly 😞

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

No branches or pull requests

7 participants