Skip to content

Commit

Permalink
Upgrade xdebug-handler to v2 and handle that coverage option is set (
Browse files Browse the repository at this point in the history
…#1510)

* Upgrade xdebug-handler to v2 and handle that `coverage` option is set in case of Xdebug 3

* remove comment block as outdated
  • Loading branch information
sidz authored and maks-rafalko committed Apr 26, 2021
1 parent d72c1f0 commit c2f04fd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -46,7 +46,7 @@
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"composer/xdebug-handler": "^1.3.3",
"composer/xdebug-handler": "^2.0",
"infection/abstract-testframework-adapter": "^0.3.1",
"infection/extension-installer": "^0.1.0",
"infection/include-interceptor": "^0.2.4",
Expand Down
17 changes: 9 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/Console/XdebugHandler.php
Expand Up @@ -50,9 +50,7 @@ final class XdebugHandler

public static function check(LoggerInterface $logger): void
{
// We force the color option unconditionally since it is able to detect the --no-ansi option
// to disable it if necessary
(new ComposerXdebugHandler(self::PREFIX, '--ansi'))
(new ComposerXdebugHandler(self::PREFIX))
->setLogger($logger)
->setPersistent()
->check()
Expand Down
6 changes: 3 additions & 3 deletions src/TestFramework/Coverage/CoverageChecker.php
Expand Up @@ -101,9 +101,9 @@ public function checkCoverageRequirements(): void
if (!$this->skipCoverage && !$this->hasCoverageGeneratorEnabled()) {
throw new CoverageNotFound(<<<TXT
Coverage needs to be generated but no code coverage generator (pcov, phpdbg or xdebug) has been detected. Please either:
- Enable pcov and run infection again
- Enable pcov and run Infection again
- Use phpdbg, e.g. `phpdbg -qrr infection`
- Enable Xdebug and run infection again
- Enable Xdebug (in case of using Xdebug 3 check that `xdebug.mode` or environment variable XDEBUG_MODE set to `coverage`) and run Infection again
- Use the "--coverage" option with path to the existing coverage report
- Enable the code generator tool for the initial test run only, e.g. with `--initial-tests-php-options -d zend_extension=xdebug.so`
TXT
Expand Down Expand Up @@ -172,7 +172,7 @@ public function checkCoverageHasBeenGenerated(
private function hasCoverageGeneratorEnabled(): bool
{
return PHP_SAPI === 'phpdbg'
|| extension_loaded('xdebug')
|| XdebugHandler::isXdebugActive()
|| extension_loaded('pcov')
|| XdebugHandler::getSkippedVersion()
|| $this->isXdebugIncludedInInitialTestPhpOptions()
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/TestFramework/Coverage/CoverageCheckerTest.php
Expand Up @@ -140,9 +140,9 @@ public function test_it_needs_code_coverage_generator_enabled_if_coverage_is_not
$this->expectException(CoverageNotFound::class);
$this->expectExceptionMessage(<<<TXT
Coverage needs to be generated but no code coverage generator (pcov, phpdbg or xdebug) has been detected. Please either:
- Enable pcov and run infection again
- Enable pcov and run Infection again
- Use phpdbg, e.g. `phpdbg -qrr infection`
- Enable Xdebug and run infection again
- Enable Xdebug (in case of using Xdebug 3 check that `xdebug.mode` or environment variable XDEBUG_MODE set to `coverage`) and run Infection again
- Use the "--coverage" option with path to the existing coverage report
- Enable the code generator tool for the initial test run only, e.g. with `--initial-tests-php-options -d zend_extension=xdebug.so`
TXT
Expand Down

0 comments on commit c2f04fd

Please sign in to comment.