pestphp / pest

Pest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
https://pestphp.com
MIT License
9.51k stars 346 forks source link

@codeCoverageIgnoreStart/End doesn't work with pcov #799

Closed renky closed 1 year ago

renky commented 1 year ago

I just switched from XDebug to pcov for code coverage analysis, because I got memory issues due to the coverage analysis (without coverage memoryusage was staying normal, and with coverage it was increasing continously, and some day when test cases have been enough, my system and my gitlab pipelines run out of memory).

After switching from xdebug to pcov this issues is solved - memory usage stays very low and it is also much faster, but the result of overall coverage is different as before, because it now ignores all annotations like @codeCoverageIgnoreStart/End or @codeCoverageIgnore for functions and classes

The question is: if this isn't a PEST issue (and I believe it isn't) then where to place this issue? phpunit? pcov? paratest (i use parallel testing - but the same issue appears without parallel)

And should it be mentioned in the pest-docs? Because there it is only mentioned that you can use xdebug and pcov, and on the same page you get the information that it is possible to ignore parts of the code with annotations - but no information that this only works with xdebug...

// both calls ignores @codeCoverageIgnore/Start/End-Annotations
php artisan test --coverage --min=90
php artisan test --coverage --min=90 --parallel

Installed Versions: brianium/paratest v7.1.3 phpunit/phpunit 10.1.2 pestphp/pest v2.6.0 laravel/framework v10.9.0

PCOV version => 1.0.11

edit: I just reduced my mininum requirement for now to continue working, but now I found out that it seems to work in gitlab-pipelines... that makes it really weired in my opinion The difference is the following:

Local environment: docker image based on phpdockerio/php:8.2-fpm, installing php-extensions with apt-get install php8.2-pcov - this file also contains xdebug, but only for debugging with xdebug.mode=develop,debug

Pipeline environment: docker image based on php:8.2-fpm-alpine3.16, installed php extensionw with mlocati/docker-php-extension-installer, calling install-php-extensions pcov

Just for test I removed xdebug from the local environment to clarifiy if this could be the reason, but also without xdebug the codeIgnore-Rules doesn't work. pcov version is the same in both cases

renky commented 1 year ago

Ok, this is more than weired...

one day later, coverage is also calculated correctly in my local environment, independent if xdebug is there or not... I don't have a clue what changed since yesterday - I remember I made a composer update yesterday evening - but the packages listed above are still on the same version.

nunomaduro commented 1 year ago

If there is any bug here, it needs to be reported to PHPUnit, not here.