Skip to content
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

It would be nice if pcov and phpunit's php-code-coverage communicated over directory filtering #49

Open
HenkPoley opened this issue May 7, 2020 · 3 comments

Comments

@HenkPoley
Copy link

HenkPoley commented May 7, 2020

With the default setting of not setting pcov.directory, pcov will latch onto either ./src, ./lib or, ./app. Leaving the end user confused why adding extra directories in phpunit.xml doesn't do anything:

sebastianbergmann/php-code-coverage#741

It would be nice if in some way, the directories whitelisted in phpunit.xml or --whitelist <dir> would change a pcov.directory-like filter, according to the Rule of Least Surprise.


For now I'll try to see if I can move CentOS and Ubuntu or Debian to write pcov.directory=. in /etc/php/7.*/mods-available/pcov.ini, but that is less optimal and takes a bit of luck to find someone who just had their breakfast and coffee and is in a good mood to apply such a change. It also doesn't 'solve' it anywhere else. Neither is it really a proper solution.


Hedging my bets: https://youtrack.jetbrains.com/issue/WI-52914

@fennik
Copy link

fennik commented Mar 7, 2021

Any update on this?

We have just run across the issue in our laravel project where we have introduced a second directory src/ additional to the default app/ directory. As a result of having 2 directories, we get 0% coverage across the board.

Haven't found a workaround yet

@kubawerlos
Copy link
Contributor

@fennik you can set pcov.directory to the project's root - this is how I did it: https://github.com/kubawerlos/php-cs-fixer-custom-fixers/blob/v2.4.1/.github/workflows/ci.yaml#L64

anomiex added a commit to Automattic/jetpack that referenced this issue Dec 23, 2021
It tries to be too smart in autodetecting `pcov.directory` and winds up
skipping files in some cases. Sigh.

krakjoe/pcov#49
@crabmusket
Copy link

crabmusket commented May 29, 2024

While investigating this, I came across this blog post. I'm going to see if xdebug handles this situation better. https://thephp.cc/articles/pcov-or-xdebug

EDIT: using xdebug for coverage seems to Just Work ™️ so I'm using that to solve this problem. Hope that helps future searchers who used pcov by default!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants