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
Add branch details to JSON report #1438
Closed
christoph-blessing
wants to merge
7
commits into
nedbat:master
from
christoph-blessing:add_branch_details_to_jsonreport
Closed
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0bb7d56
Extend json report test
christoph-blessing b387359
Add branch details to json report
christoph-blessing 99ed2db
Add exiting branch arc to json report test
christoph-blessing 97b2ac8
Update branch details format
christoph-blessing d6f9893
Fix linting errors
christoph-blessing b8e1e50
Merge branch 'master' into add_branch_details_to_jsonreport
nedbat f0aa16f
Merge branch 'master' into add_branch_details_to_jsonreport
nedbat File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Mm, in Slipcover, I chose to output
executed_branches
andmissing_branches
directly next toexecuted_lines
, etc., as a list of tuples (which in JSON becomes a list of 2-element lists). With->exit
branches being shown as[x,0]
"tuples" (wherex
is the source line).We don't have to have the same format, but it would be nice...
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.
Hey, thanks for the feedback. I changed the format to the one you requested.
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.
Cool! Thank you.
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 curious why 0 is better than -1 for exit?
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.
Mm, I think both work well. I just a hope Ed to pick 0. Do you have a reason why -1 is better?
.. Juan
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.
Internally, entering and exiting a code object is represented in arcs as negative numbers. From one of the docstrings:
Here's some actual data from the .coverage file:
I'm curious why you haven't seen negative numbers other than -1 in testing.
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.
It's easy to get other negative numbers. This is using the code from this pull request:
then:
missing_branches mentions -3, because the exit was never taken from the code starting at line 3.
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.
For that
.py
, Slipcover outputs a missing (5,5) branch, since really it is a same-line branch (to thereturn
statement), below. For branches that exit a function, it outputs 0 as the destination... As in the (2,0) branch forI could change that to -1, but to change that to something dependent upon where the code starts would take more effort.
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.
Maybe we need to talk about the value of coverage.py and slipcover producing the same data, vs coverage.py producing data with more information?
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.
Right... Is there truly value in encoding the starting line of the code in the branch destination? How would that help a user?
I guess the more the packages differ in the data they collect, potentially the more difficult a Slipcover-based collector for coverage.py might become... which, of course, at this point is just an idea.
In this case in particular, it seems like we'd generate different data anyway, because of the same-line branch.