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
False positive uncovered mutant with switch(true)
and switch(false)
#819
Comments
Duplicate of #34 This is how coverage looks like: It boils down to how PHP works internally, please read exactly the same issue we created earlier #34 See Derick's explanation here https://bugs.xdebug.org/view.php?id=1479#c4450 I would say it won't be fixed on Infection side unless someone wants to do some magic to make it work (similar to how @BackEndTea did it for array coverage) Closing for now, feel free to reopen, fix, and discuss farther though. |
Probably, as a quick fix, it makes sense to not mutate |
Is the switch never covered? Or only when its switching over true/a constant? If its never covered we can always skip that; otherwise only for true and false mutator |
I only saw not covered Let's do a quick fix to not mutate |
Happy to help, could you give me any pointers of where to look? Never got my hands dirty on infection's codebase |
Probably somewhere around here:
My best bet would be a check to see if the direct parent is the switch statement. |
For completeness sake this should also be for the |
Harder, but better, will be to tag a switch as covered if any single line inside of it is covered. |
I think we only need to check the case statements for that. So wed only need to go 1 level deep. |
Or up, unconditionally tagging an uncovered switch as covered every time we see a covered case statement. |
switch(true)
and switch(false)
Infection is reporting an uncovered mutant on the repository above:
This is however a false positive. That line is indeed covered, and the switch from true to false does break tests.
You can check by cloning,
composer -o install; make
. This runs phpunit and infection in sequence, infection recycling test results from phpunit. Letting infection generate its own reports makes no difference.Build: https://ci.auronconsulting.co.uk/teams/main/pipelines/favicon-finder-master/jobs/analyze-master/builds/1
The text was updated successfully, but these errors were encountered: