-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Disable Xdebug in subprocesses when it is not used #5989
Conversation
public function testOne(): void | ||
{ | ||
$this->assertTrue(extension_loaded('xdebug')); | ||
$this->assertSame('', (string) ini_get('xdebug.mode')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when -d xdebug.mode=off
is passed, xdebug.mode
returns ''
:
➜ phpunit git:(xdebugsub) ✗ php -d 'xdebug.mode=off' test.php
string(0) ""
➜ phpunit git:(xdebugsub) ✗ php -d 'xdebug.mode=coverage' test.php
string(8) "coverage"
➜ phpunit git:(xdebugsub) ✗ cat test.php
<?php
var_dump((string) ini_get('xdebug.mode'));
6c71e7f
to
1090876
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5989 +/- ##
=========================================
Coverage 94.67% 94.67%
- Complexity 6406 6408 +2
=========================================
Files 694 694
Lines 19189 19191 +2
=========================================
+ Hits 18167 18169 +2
Misses 1022 1022 ☔ View full report in Codecov by Sentry. |
60ecc0f
to
e4251bb
Compare
I think this one is now good to go |
@@ -0,0 +1,38 @@ | |||
--TEST-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this test be moved in a different folder?
Cherry-picked into |
Blogged about it: https://staabm.github.io/2024/10/19/phpunit-codesprint-munich.html |
before this PR xdebug was only auto-disabled for PHPT.
as of this PR we disable xdebug for all sub-processes to make them faster - but only if no active debugger is attached.
this means subprocess isolated tests can still be debugged without the need for a additional cli-option or config setting changed just by attaching e.g. PHPStorm (so no change in DX).
I initially tried disabling xdebug for the whole sub-process by not loading the extension at all, but this would either require a new composer/xdebug-handler dependency or a way more involved fix.
disabling xdebug already provides most perf benefits.
Benchmark (xdebug loaded, but no debugger attached):
/c/tools/php83/php phpunit tests/end-to-end/data-provider/log-junit-isolation.phpt
with phpunit@a82cc0548 takes 2.5 - 2.6 seconds (phpunit reported runtime)After this PR:
/c/tools/php83/php phpunit tests/end-to-end/data-provider/log-junit-isolation.phpt
takes 0.5-0.6 secondstested with PHP 8.3.11 with Xdebug v3.4.0beta1 on windows11x64
php.ini settings: