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

Debug mode of Xdebug 2 is not disabled for PHPT tests #4529

Closed
ste93cry opened this issue Nov 28, 2020 · 0 comments
Closed

Debug mode of Xdebug 2 is not disabled for PHPT tests #4529

ste93cry opened this issue Nov 28, 2020 · 0 comments
Labels
type/bug Something is broken

Comments

@ste93cry
Copy link
Contributor

Q A
PHPUnit version 9.4.3
PHP version 7.4.12
Installation Method Composer

Composer info

doctrine/instantiator              1.4.0   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
myclabs/deep-copy                  1.10.2  Create deep copies (clones) of your objects
nikic/php-parser                   v4.10.2 A PHP parser written in PHP
phar-io/manifest                   2.0.1   Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    3.0.2   Library for handling version information and constraints
phpdocumentor/reflection-common    2.2.0   Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock  5.2.2   With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.
phpdocumentor/type-resolver        1.4.0   A PSR-5 based resolver of Class names, Types and Structural Element Names
phpspec/prophecy                   1.12.1  Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          9.2.4   Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          3.0.5   FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                3.1.1   Invoke callables with a timeout
phpunit/php-text-template          2.0.4   Simple template engine.
phpunit/php-timer                  5.0.3   Utility class for timing
phpunit/phpunit                    9.4.3   The PHP Unit Testing framework.
sebastian/cli-parser               1.0.1   Library for parsing CLI options
sebastian/code-unit                1.0.8   Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 2.0.3   Looks up which function or method a line of code belongs to
sebastian/comparator               4.0.6   Provides the functionality to compare PHP values for equality
sebastian/complexity               2.0.2   Library for calculating the complexity of PHP code units
sebastian/diff                     4.0.4   Diff implementation
sebastian/environment              5.1.3   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 4.0.3   Provides the functionality to export PHP variables for visualization
sebastian/global-state             5.0.2   Snapshotting of global state
sebastian/lines-of-code            1.0.2   Library for counting the lines of code in PHP source code
sebastian/object-enumerator        4.0.4   Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector         2.0.4   Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        4.0.4   Provides functionality to recursively process PHP variables
sebastian/resource-operations      3.0.3   Provides a list of PHP built-in functions that operate on resources
sebastian/type                     2.3.1   Collection of value objects that represent the types of the PHP type system
sebastian/version                  3.0.2   Library that helps with managing the version number of Git-hosted PHP projects
symfony/polyfill-ctype             v1.20.0 Symfony polyfill for ctype functions
theseer/tokenizer                  1.2.0   A small library for converting tokenized PHP source code into XML and potentially other formats
webmozart/assert                   1.9.1   Assertions to validate method input/output with nice error messages.

Summary

While trying to support Xdebug 3 with commit 312641d a bug has been introduced with Xdebug 2 that does not disable the "debug" side. In particular, the xdebug.default_enable=0 option is now missing causing Xdebug to work as if it was fully enabled and operational instead of just enabling the code coverage mode

Current behavior

Xdebug prints debug information (e.g. stacktraces, etc) when an error is thrown, breaking PHPT assertions with unexpected additional lines of output

PHPUnit 9.4.3 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 00:03.534, Memory: 10.00 MB

There was 1 failure:

1) /opt/project/tests/test.phpt
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
-Fatal error: Class FooClass contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Serializable::serialize, Serializable::unserialize) in /opt/project/src/test.php on line 3
+Fatal error: Class FooClass contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Serializable::serialize, Serializable::unserialize) in /opt/project/src/test.php on line 3
+
+Call Stack:
+    0.0001     394880   1. {main}() Standard input code:0
+    0.1640    1210624   2. require('/opt/project/tests/test.php') Standard input code:57
+    0.1709    1212160   3. require_once('/opt/project/src/test.php') /opt/project/tests/test.php:3

/opt/project/tests/test.phpt:1

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

Generating code coverage report in Clover XML format ... done [00:00.072]

How to reproduce

$ tree
.
|-- phpunit.xml.dist
|-- src
|   `-- test.php
`-- tests
    `-- test.phpt

phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
  <coverage>
    <include>
      <directory suffix=".php">src</directory>
    </include>
  </coverage>
  <testsuites>
    <testsuite name="Test Suite">
      <directory suffix=".phpt">tests</directory>
    </testsuite>
  </testsuites>
</phpunit>

test.php

<?php

class FooClass implements \Serializable
{
}

test.phpt

--FILE--
<?php

require_once __DIR__ . '/../src/test.php';
--EXPECTF--
Fatal error: Class FooClass contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Serializable::serialize, Serializable::unserialize) in %s on line %d

Expected behavior

Test suite should pass and code coverage should be collected

@ste93cry ste93cry added the type/bug Something is broken label Nov 28, 2020
@sebastianbergmann sebastianbergmann changed the title Xdebug 2.x debug mode is not disabled when code coverage is enabled Debug mode of Xdebug 2 is not disabled for PHPT tests Nov 28, 2020
This was referenced Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants