infection: Infection wrongly claims "continue to break" mutation would be uncovered

Question Answer
Infection version 0.26.21 (phar)
Test Framework version 10.2.6 (phar)
PHP version 8.2.8 / 8.3.0beta1
Platform Fedora 38
Github Repo https://github.com/theseer/infection-bug

The above repository should be self-contained - except for PHP itself.

When running ./tools/infection, the report (see infection.txt) claims, the mutation to change the continue in the sample code to break would be uncovered.

That’s wrong, as manually changing the Code and running PHPUnit shows.

Interestingly enough, when extracting the example and pasting it into the Infection Playground ( https://infection-php.dev/r/4evk) this same change is claimed as covered.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

Already on it 😉

I totally agree with you for not covered executable lines of code. I just didn’t know infection is that smart 😃

The only thing I do not agree with is that a mutation on a proclaimed non-executable-line (falsely, i know) can ever be covered. But given the situation only arose because of a bug / optimizer side effect, this certainly qualifies as an edge case. I wouldn’t even know what the correct behavior would be in that case, e.g. skip the mutation or require to run tests.

So, yes, let’s just keep this issue closed because it’s not worth the effort of considering a change.

Found it.

It’s an opcache issue that apparently throws of pcov:

$ php ./tools/phpunit --coverage-clover=php://stdout | grep -c 'num="9"'
0

$ php -d opache.enable=0 -d opcache.enable_cli=0 ./tools/phpunit --coverage-clover=php://stdout | grep -c 'num="9"'
1

I guess that qualifies as a bug in pcov?