-
Notifications
You must be signed in to change notification settings - Fork 387
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
Try to fix branch coverage with async calls bug #158
Try to fix branch coverage with async calls bug #158
Conversation
Hi @MarcoRossignoli, sorry for the delay in responding to this. Will take a look and get back to you |
} | ||
foreach (var branchToRemove in branchesToRemove) | ||
{ | ||
document.Value.Branches.Remove(branchToRemove.Key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on next runtime version we can remove directly during enumeration(Dictionary<(int Line, int Ordinal), Branch>
) dotnet/coreclr#18854 https://github.com/dotnet/corefx/issues/31459
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very interested in helping to get this pr merged - @MarcoRossignoli do you need to update this pr now that they released a new version of the clr last week?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB. It's not my intention put pressure on maintainers!@tonerdo take all time you need, and thank's a lot for your work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love to see this merged. Anything holding this back, @tonerdo ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve merge conflicts and this is good to go! Apologies for the hold up on this
No problem. Now result to this https://github.com/abe545/CoverletAwaitBranchCoverage/tree/master:
|
@tonerdo no need to apologize for the delay, and thanks for all your hard work on this project! |
…overageasynccalls Try to fix branch coverage with async calls bug
@kevindqc could you produce a simple repro? |
I have a similar issue with this "ghost branches" which are never covered.
This code generates 4 branches, 2 of which I'm never able to cover my tests:
The generated branches in my coverage.json are (notice the
Line 27 in my code is precisely the async await one: hope it's useful |
@pape77 could create a full solution with you code?I see some references and would be great have buildable solution(sln) with simple 2 project similar to #113 (comment), you can attach it here if you don't want to create a new repo. |
@MarcoRossignoli In folder "test-results" is the generated coverage.json that I get, you should get the same (50% branch coverage on Application proj, due to this two branches not covered in the async method) Edit: I removed the usage of the cache to make it more clear and visible. Now you will see 2 branches on line 23. One of which is never hit by tests. And won't be possible to hit |
@pape77 thank's now I'm OOF but I'll take a look ASAP |
fixes #113
The issue is related to compiler generated state machine:
If task complete synchronously this branch doens't hit.
I borrowed this idea from OpenCover.
I tested 2 strategies:
3edf519#diff-9eb1afa9bd8141e48d456c120df924caR185 this one force hit on not covered branch
06a5e59#diff-9eb1afa9bd8141e48d456c120df924caR199 this one remove completely the branch if not hitted(but other one yes)
I prefer remove the branch...is more real than force hit.
Let me know what do you think.
/cc @tonerdo