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

Empty lines and certain statements on their own being marked as uncovered #19

Closed
wheybags opened this issue Sep 12, 2014 · 2 comments
Closed

Comments

@wheybags
Copy link

with this code:

# blah.rb
def foo(x)
    if x == 2
        blah = 5 
    else
        blah = 7 
    end 

    return blah
end

# test.rb
...

coverband.start

foo 1
foo 2

coverband.stop
coverband.save
Coverband::Reporter.report

I get
screen shot 2014-09-12 at 03 00 34 p m

It seems to me like this should be 100% covered, and those lines marked as uncovered are incorrect.

@danmayer
Copy link
Owner

I am traveling for awhile so it will take me a bit of time to dig into this. Could you give me a bit more info to help me debug.

What OS are you on?
What version of Ruby are you using?
Are there any other gems included in the project when running the example?

thanks, hopefully I can figure out a fix, using set_trace_func isn't perfect in what it reports back. I still need to look at using some of the newer methods available to release a Ruby 2.1.2+ only version of coverband which would be even faster and have better accuracy.

@danmayer
Copy link
Owner

So the issue is that when using the manual start and stop you still need to take a baseline. This is because set_trace_func only captures the lines executed, and block ending lines aren't considered executed, they just halt the current scope. The baseline run, recorded various things that never get covered in a way that is considered executed, it is stored as a baseline of what coverage looks like just loading ruby files. After coverband has run recording actual executed lines that data is merged with the baseline. This gives the complete picture of code coverage. You can see this in the screenshot I have included.

screenshot 2014-10-19 at 11 43 18 pm

I created a tiny example git repo, which shows the code you were working with. It includes a new file called baseline.rb If you run that it records the baseline data into tmp, which gets merged into the coverage data when you run your original test.rb

I hope this helps explain what was going on and makes it a little more clear how coverband works. Let me know if you have any more questions or comments.

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