Disable Xdebug in subprocesses when it is not used#5989
Closed
staabm wants to merge 1 commit intosebastianbergmann:mainfrom
Closed
Disable Xdebug in subprocesses when it is not used#5989staabm wants to merge 1 commit intosebastianbergmann:mainfrom
staabm wants to merge 1 commit intosebastianbergmann:mainfrom
Conversation
staabm
commented
Oct 13, 2024
| public function testOne(): void | ||
| { | ||
| $this->assertTrue(extension_loaded('xdebug')); | ||
| $this->assertSame('', (string) ini_get('xdebug.mode')); |
Contributor
Author
There was a problem hiding this comment.
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
staabm
commented
Oct 13, 2024
Contributor
Author
|
I think this one is now good to go |
staabm
commented
Oct 14, 2024
| @@ -0,0 +1,38 @@ | |||
| --TEST-- | |||
Contributor
Author
There was a problem hiding this comment.
should this test be moved in a different folder?
Owner
|
Cherry-picked into |
Contributor
Author
|
Blogged about it: https://staabm.github.io/2024/10/19/phpunit-codesprint-munich.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.phptwith 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.phpttakes 0.5-0.6 secondstested with PHP 8.3.11 with Xdebug v3.4.0beta1 on windows11x64
php.ini settings: