-
-
Notifications
You must be signed in to change notification settings - Fork 438
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 support for conditional coverage #660
Comments
@tpansino I haven't thought about how hard it would be to implement something like this. Generally, behavior within a line is not visible to coverage.py, since the Python trace function works on a line-by-line basis. Can you show some examples of how the results would be reported? That's often another challenge with information-rich features like this. |
Original comment by Thomas Pansino (Bitbucket: tpansino, GitHub: tpansino)
That's the problem where I think
Agreed. I have some initial thoughts on this, but since a picture is worth a thousand words, I'll work on a screenshot of how I think the text report and HTML report could be modified to display this efficiently. |
Original comment by d (Bitbucket: desmaj, GitHub: desmaj) There are condition / decision coverage report examples in the instrumental docs here. I think it would be straightforward to incorporate this in textual coverage reports. I'll be very interested to see the ideas that @tpansino has for displaying instrumental's coverage information. |
Original comment by Thomas Pansino (Bitbucket: tpansino, GitHub: tpansino) Ok, I've played around with Here is the test script
So I have 2 branches that aren't covered, and 2/3 conditions uncovered. With branching and conditional coverage enabled, the text report might look like: And the detailed HTML report for For some context, here is the coverage report using And the And the additional Conditional Coverage page which links from line 18, conditional column: I like the color-coding visual truth table that the Perl report offers quite a bit, and would love to do that in lieu of all the sentences in the hover box, but the implementation of the Overall I think implementing the visual reporting changes would be much less difficult than the underlying coverage tracking changes. For that, we have a few options. The first of course is trying to directly leverage the techniques @desmaj (Matt) is using. This seems like it would be a significant departure from what Second, Matt has alternatively suggested that we take the approach of using The third option here as I see it would be to go the other direction and port some of the reporting code in I'm curious what @nedbat and maybe others in the community think of these approaches. |
Hi, I would like this too.
But coverage cannot check the 2 possible return values. And this is not pythonic:
Especially now that python3.7 was released coming with inline tracing capabilities. If you can give me some insights to start working on this project, I can give it a try. Cheers. |
@luisfmelo Even if we implement conditional coverage, it wouldn't help in your situation. You don't have a condition. Look at the disassembly:
The same sequence of instructions is executed no matter what. |
Hey @nedbat wanted pump this issue back. I'm particular interested in this feature for the pythonfuzz library we recently released (which uses coverage.py) . As conditional branch coverage is critical to fuzzing for example:
For a coverage guided fuzzer without conditional branch coverage it would be pretty much impossible to generate 'FUZ' but with conditional branch coverage feedback it would be pretty easy and quick. |
We can talk some more about how this could be accomplished, though it feels like a big lift, and I should get 5.0 out the door before taking on more large changes. BTW: I see this line in pythonfuzz: |
Thanks for the quick reply. I would be happy to either help with this feature myself or even sponsor this feature if there is someone who is more familiar with coveragepy and have some spare time. Regarding the |
At a quick look, you are doing this:
which could instead be:
There is one list created in the second way that isn't in the first. I hope you can afford one list. The |
Thanks, sounds good. I'll push this change and do a benchmark I think it should work for me. when do you think 5.0 will be out (estimate)? |
5.0 alphas are available now, and feedback is appreciated. I'm hoping to have the beta this month. |
This is very closely related, if not exactly the same thing as #292, or vice versa, isn't it? |
@mjpieters Yes, it's the same feature. We could potentially close as a duplicate, though I think the examples I provided of what the coverage report looks like in Perl/could look like with |
Sorry, I am not able to find this feature anywhere in |
@sobolevn this issue has meandered a bit. What feature exactly are you looking for? |
I was asking about this particular message #660 (comment) |
I see. #660 (comment) is a suggestions by @tpansino. It is not implemented yet in coverage.py. I'm not sure the status of their work. |
Stricter than statement coverage. The coverage library does not yet have support for conditional coverage <nedbat/coveragepy#660>, which is even stricter.
Stricter than statement coverage. The coverage library does not yet have support for conditional coverage <nedbat/coveragepy#660>, which is even stricter.
Stricter than statement coverage, so I had to take the coverage minimum down one percentage point. The coverage library does not yet have support for conditional coverage <nedbat/coveragepy#660>, which is even stricter.
Stricter than statement coverage, so I had to take the coverage minimum down two percentage points. The coverage library does not yet have support for conditional coverage <nedbat/coveragepy#660>, which is even stricter.
Is there any update on this? Is this feature possible to implement? It would be very useful. |
Originally reported by Thomas Pansino (Bitbucket: tpansino, GitHub: tpansino)
Coming from the Perl world with its excellent
Devel::Cover
module, I'm quite surprised that the most popular equivalent coverage package in Python doesn't have any support for conditional coverage. This can be a useful metric similiar to branch coverage to ensure all combinations of boolean conditionals are tested properly.The best tool I've found so far to measure this is @desmaj's
instrumental
utility, which is in need of some updates for Python 3 compatibility and some general polishing and love.I'm thinking there may be an opportunity here to incorporate some of the work done in
instrumental
intocoverage.py
. I don't know that I have the Python expertise to do the work myself, but I'm happy to learn and contribute in whatever way I can.First thing's first - where does this idea fall on the
coverage.py
roadmap?The text was updated successfully, but these errors were encountered: