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

xdebug mode detection ignores CLI option (-dxdebug.mode=coverage) #1002

Open
pionl opened this issue Jun 14, 2023 · 2 comments
Open

xdebug mode detection ignores CLI option (-dxdebug.mode=coverage) #1002

pionl opened this issue Jun 14, 2023 · 2 comments

Comments

@pionl
Copy link

pionl commented Jun 14, 2023

Q A
PHPUnit version 9.6.9
PHP version 8.1.20
Installation Method Composer

Summary

Lately we have changed our docker setup that sets XDEBUG_MODE=debug (based on .env file) and it broke our execution of tests with code coverage in PHPStorm.

Currently we are able to bypass it by using different PHPStorm run configuration that forces XDEBUG_MODE=coverage.

Current behavior

PHPUnit outputs a warning:

Warning:       XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set

PHPStorm runs the tests with php -dxdebug.mode=coverage /app/vendor/phpunit/phpunit/phpunit which ensures that xdebug should use coverage value but PHPUnit uses XDEBUG_MODE environment variable with higher priority.

I've checked this by checking xdebug_info.

debug.php

<?php

xdebug_info();
XDEBUG_MODE=debug php debug.php | grep xdebug.mode
...
xdebug.mode (through XDEBUG_MODE) => debug
XDEBUG_MODE=debug php -dxdebug.mode=coverage debug.php | grep xdebug.mode
...
xdebug.mode (through XDEBUG_MODE) => debug => coverage

I was able to test this in PHPUnit 9 (don't have a project on PHP10), but the code seems same?

Is this expected behavior?

How to reproduce

XDEBUG_MODE=debug php -dxdebug.mode=coverage ./vendor/phpunit/phpunit/phpunit --coverage-text

Expected behavior

Code coverage should be collected.

Thank you for your time!

@pionl pionl added the type/bug label Jun 14, 2023
@sebastianbergmann sebastianbergmann transferred this issue from sebastianbergmann/phpunit Jun 14, 2023
@sebastianbergmann
Copy link
Owner

The code for PHPUnit 9.6 that determines whether Xdebug 3 is loaded and configured for code coverage is here.

The code for PHPUnit 10 is different in that it uses xdebug_info('mode') when available.

Can you please investigate whether backporting the xdebug_info('mode') query from the php-code-coverage version used by PHPUnit 10 to the one used by PHPUnit 9 would solve your problem? Thanks!

@pionl
Copy link
Author

pionl commented Jun 20, 2023

Hi @sebastianbergmann thank you for the answer, will look into it this week!

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

No branches or pull requests

2 participants