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
Set XDEBUG_MODE for processes with coverage #1518
Merged
sanmai
merged 43 commits into
infection:master
from
sanmai:pr/2020-05/autodetect-XDEBUG_MODE
Nov 10, 2021
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
5390f63
Set XDEBUG_MODE for processes with coverage
sanmai 317e5ce
Don't even mention XDEBUG_MODE
sanmai f71de68
Add a test
sanmai fd77c35
Address PCOV
sanmai 90017c6
Simplify Dockerfiles
sanmai 6dd84fe
Fix PHPStan
sanmai a8a3db7
Fix tests in Windows
sanmai a645bee
Reduce epsilon
sanmai 99162ef
Should use XDEBUG_MODE=coverage
sanmai 6f72869
Add Xdebug 2 to CI
sanmai 4999b9a
Fix tests on Windows by not assuming a new line
sanmai 97ba8e1
cs
sanmai 5fd95df
Merge branch 'master' into pr/2020-05/autodetect-XDEBUG_MODE
sanmai 41433ee
Revert everything to where it was
sanmai aa1e089
Disable XDebug on CI
sanmai fd56f5d
Put everything back together after we proved it works
sanmai 8af83b2
Merge branch 'master' into pr/2020-05/autodetect-XDEBUG_MODE
sanmai 7b12fc4
We can know that Xdebug was offloaded
sanmai 8070082
Return useful notices
sanmai ceee8e2
Fix tests
sanmai 9f6d313
Fix it
sanmai ae72703
Another check for Xdebug
sanmai c3aa985
Code Style
sanmai 9925caf
Update OriginalPhpProcess
sanmai cccb00f
Fix SA issues
sanmai 51f3d8f
Also check for PCOV and PHPDBG
sanmai ba71b3b
composer.lock: update deps
sanmai b59fe4f
Actually, undo the update
sanmai 2d9435e
No quotes required here apparently
sanmai 2b6b4d0
Fix e2e tests collecting coverage outside of Infection
sanmai a7c2f2f
Skip E2ETest if Xdebug isn't enabled
sanmai 394e1dc
There's something wrong on Windows
sanmai 4597545
Explain the why
sanmai eec4a33
Move override close to the point of use
sanmai e958091
Fix negation
sanmai db7bd12
Rename xdebug-coverage.ini
sanmai 2b7aa7b
Merge branch 'master' into pr/2020-05/autodetect-XDEBUG_MODE
sanmai e363c79
Merge branch 'master' into pr/2020-05/autodetect-XDEBUG_MODE
sanmai 50ee06f
Make it all more readable
sanmai 17f84ee
Merge branch 'pr/2020-05/autodetect-XDEBUG_MODE' of github.com:sanmai…
sanmai 4270a9b
Patch up to master
sanmai 2b8a324
Fix tests
sanmai 20a9b99
Fix this
sanmai File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
xdebug.mode=off |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
use Infection\FileSystem\Locator\FileNotFound; | ||
use Infection\TestFramework\Coverage\JUnit\JUnitReportLocator; | ||
use Infection\TestFramework\Coverage\XmlReport\IndexXmlCoverageLocator; | ||
use function ini_get as ini_get_unsafe; | ||
use const PHP_EOL; | ||
use const PHP_SAPI; | ||
use function Safe\preg_match; | ||
|
@@ -175,6 +176,7 @@ private function hasCoverageGeneratorEnabled(): bool | |
|| XdebugHandler::isXdebugActive() | ||
|| extension_loaded('pcov') | ||
|| XdebugHandler::getSkippedVersion() !== '' | ||
|| ini_get_unsafe('xdebug.mode') !== false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means we're using Xdebug 3 (as |
||
|| $this->isXdebugIncludedInInitialTestPhpOptions() | ||
|| $this->isPcovIncludedInInitialTestPhpOptions(); | ||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
/** | ||
* This code is licensed under the BSD 3-Clause License. | ||
* | ||
* Copyright (c) 2017, Maks Rafalko | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* * Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Infection\Tests\Process; | ||
|
||
use function extension_loaded; | ||
use Infection\Process\OriginalPhpProcess; | ||
use function ini_get as ini_get_unsafe; | ||
use const PHP_SAPI; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Process\Process; | ||
|
||
final class OriginalPhpProcessTest extends TestCase | ||
{ | ||
public function test_it_extends_symfony_process(): void | ||
{ | ||
$process = new OriginalPhpProcess([]); | ||
|
||
$this->assertInstanceOf(Process::class, $process); | ||
} | ||
|
||
public function test_it_takes_command_line(): void | ||
{ | ||
$process = new OriginalPhpProcess(['foo']); | ||
$this->assertStringContainsString('foo', $process->getCommandLine()); | ||
} | ||
|
||
/** | ||
* @group integration | ||
*/ | ||
public function test_it_injects_xdebug_env_vars(): void | ||
{ | ||
$process = new OriginalPhpProcess(['env']); | ||
$process->run(null, ['TESTING' => 'test']); | ||
|
||
if ( | ||
!extension_loaded('pcov') && | ||
PHP_SAPI !== 'phpdbg' && | ||
( | ||
ini_get_unsafe('xdebug.mode') === false || | ||
ini_get_unsafe('xdebug.mode') === '' | ||
) | ||
) { | ||
$this->assertStringContainsString('XDEBUG_MODE=coverage', $process->getOutput()); | ||
} else { | ||
$this->assertStringNotContainsString('XDEBUG_MODE=coverage', $process->getOutput()); | ||
} | ||
|
||
$this->assertStringContainsString('TESTING=test', $process->getOutput()); | ||
} | ||
} |
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.
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.
not sure I understand this block.
XDEBUG_MODE=coverage
whenpcov
is loaded, for example?In the end the user is still in control: they can provide XDEBUG_MODE=coverage on their own.
- is it true? If user passesXDEBUG_MODE=debug
and Xdebug is loaded (with, let's say,off
mode), then this new code will override it byXDEBUG_MODE=coverage
, no?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.
XDEBUG_MODE=coverage
even if they have PCOV loaded. We can't guarantee other tools will pick this up, but at least we're not standing in the way.XDEBUG_MODE=debug
is no use for us, we have to override it withXDEBUG_MODE=coverage
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.
OK, all should be much more clear in
shallExtendEnvironmentWithXdebugMode
below.