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

Call to undefined function get_debug_type() #1470

Closed
canvural opened this issue Jan 17, 2021 · 4 comments
Closed

Call to undefined function get_debug_type() #1470

canvural opened this issue Jan 17, 2021 · 4 comments

Comments

@canvural
Copy link
Sponsor

canvural commented Jan 17, 2021

Question Answer
Infection version 0.20.x-dev@6035c1566af6a5a8d833a276351e5e18ed412305, 0.20.1, 0.20.0
Test Framework version PHPUnit/PhpSpec x.y.z
PHP version 7.4.11
Platform Ubuntu
Github Repo -
PHPUnit 9.5.0
XDebug 3.0.2

My issue is similar to #1384 but my configuration is valid I think.

My configuration
{
    "source": {
        "directories": [
            "app"
        ],
        "excludes": [
            "Mail",
            "Nova",
            "Providers",
            "Policies"
        ]
    },
    "logs": {
        "text": "infection.log"
    },
    "mutators": {
        "@default": true
    }
}

I'm running infection with ./infection.phar --coverage=tests/_reports "--initial-tests-php-options=-d memory_limit=-1"

With `-vvv` option this is the output
Box Requirements Checker
========================

> Using PHP 7.4.11
> PHP is using the following php.ini file:
  /usr/local/etc/php/php.ini

> Checking Box requirements:
  ✔ The application requires the version "^7.4 || ^8.0" or greater.
  ✔ The application requires the extension "zlib".
  ✔ The application requires the extension "dom".
  ✔ The application requires the extension "json".
  ✔ The application requires the extension "libxml".
  ✔ The package "nikic/php-parser" requires the extension "tokenizer".
  
                                                                                
 [OK] Your system is ready to run the application.                              
                                                                                

[debug] Checking INFECTION_ALLOW_XDEBUG
[debug] The Xdebug extension is loaded (3.0.2)
[debug] Async signals enabled (SIGINT = SIG_IGN)
[debug] Process restarting (INFECTION_ALLOW_XDEBUG=internal|3.0.2|1|*|*)
[debug] Running '/usr/local/bin/php' './infection' '--coverage=tests/_reports' '--initial-tests-php-options=-d memory_limit=-1' '-j4' '-vvv' '--ansi'

Box Requirements Checker
========================

> Using PHP 7.4.11
> PHP is using the following php.ini file:
  /tmp/KGo3AY

> Checking Box requirements:
  ✔ The application requires the version "^7.4 || ^8.0" or greater.
  ✔ The application requires the extension "zlib".
  ✔ The application requires the extension "dom".
  ✔ The application requires the extension "json".
  ✔ The application requires the extension "libxml".
  ✔ The package "nikic/php-parser" requires the extension "tokenizer".
  
                                                                                
 [OK] Your system is ready to run the application.                              
                                                                                

[debug] Checking INFECTION_ALLOW_XDEBUG
[debug] Restarted (234 ms). The Xdebug extension is not loaded
[debug] Async signals enabled (SIGINT = SIG_DFL)

    ____      ____          __  _
   /  _/___  / __/__  _____/ /_(_)___  ____
   / // __ \/ /_/ _ \/ ___/ __/ / __ \/ __ \
 _/ // / / / __/  __/ /__/ /_/ / /_/ / / / /
/___/_/ /_/_/  \___/\___/\__/_/\____/_/ /_/

Infection - PHP Mutation Testing Framework version 0.20.0@735506ce5fc35dd504c9ba147d5fe0554898b232


Running initial test suite...

PHPUnit version: 9.5.0

  783 [============================]  1 min

Fatal error: Uncaught Error: Call to undefined function _HumbugBoxa55ec68a3f71\Symfony\Component\Console\get_debug_type() in phar:///var/www/html/infection/vendor/symfony/console/Application.php:489
Stack trace:
#0 phar:///var/www/html/infection/vendor/symfony/console/Application.php(478): _HumbugBoxa55ec68a3f71\Symfony\Component\Console\Application->doRenderThrowable(Object(InvalidArgumentException), Object(_HumbugBoxa55ec68a3f71\Symfony\Component\Console\Output\StreamOutput))
#1 phar:///var/www/html/infection/vendor/symfony/console/Application.php(83): _HumbugBoxa55ec68a3f71\Symfony\Component\Console\Application->renderThrowable(Object(InvalidArgumentException), Object(_HumbugBoxa55ec68a3f71\Symfony\Component\Console\Output\StreamOutput))
#2 phar:///var/www/html/infection/vendor/symfony/console/Application.php(103): _HumbugBoxa55ec68a3f71\Symfony\Component\Console\Application->_HumbugBoxa55ec68a3f71\Symfony\Component\Console\{closure}(Object(InvalidArgumentException))
#3 phar:///var/www/html/infection/bin/infection(71): in phar:///var/www/html/infection/vendor/symfony/console/Application.php on line 489
[debug] Restarted process exited 255
PHPUnit config
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  backupGlobals="false"
  backupStaticAttributes="false"
  bootstrap="vendor/autoload.php"
  colors="true"
  convertErrorsToExceptions="true"
  convertNoticesToExceptions="true"
  convertWarningsToExceptions="true"
  processIsolation="false"
  executionOrder="random"
  stopOnFailure="true"
  xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
>
  <coverage
    processUncoveredFiles="true"
  >
    <include>
      <directory suffix=".php">./app</directory>
    </include>
    <exclude>
      <directory suffix=".php">./app/Nova</directory>
    </exclude>
    <report>
      <clover outputFile="tests/_reports/logs/clover.xml"/>
      <html outputDirectory="tests/_reports/coverage/html" lowUpperBound="35" highLowerBound="70"/>
      <xml outputDirectory="tests/_reports/coverage/coverage-xml"/>
    </report>
  </coverage>
  <testsuites>
    <testsuite name="Feature">
      <directory suffix="Test.php">./tests/Feature</directory>
    </testsuite>
    <testsuite name="Unit">
      <directory suffix="Test.php">./tests/Unit</directory>
    </testsuite>
  </testsuites>
  <extensions>
    <extension class="Tests\Bootstrap"/>
  </extensions>
  <php>
    <server name="APP_ENV" value="testing"/>
    <server name="CACHE_DRIVER" value="array"/>
    <server name="SESSION_DRIVER" value="array"/>
    <server name="QUEUE_DRIVER" value="sync"/>
    <server name="MAIL_DRIVER" value="array"/>
    <server name="DB_CONNECTION" value="mysql"/>
    <server name="TELESCOPE_ENABLED" value="false"/>
    <server name="APP_CONFIG_CACHE" value="bootstrap/cache/config.phpunit.php"/>
    <server name="APP_SERVICES_CACHE" value="bootstrap/cache/services.phpunit.php"/>
    <server name="APP_PACKAGES_CACHE" value="bootstrap/cache/packages.phpunit.php"/>
    <server name="APP_ROUTES_CACHE" value="bootstrap/cache/routes.phpunit.php"/>
    <server name="APP_EVENTS_CACHE" value="bootstrap/cache/events.phpunit.php"/>
    <ini name="display_errors" value="true"/>
  </php>
  <logging>
    <junit outputFile="tests/_reports/coverage/phpunit.junit.xml"/>
    <testdoxText outputFile="tests/_reports/testdox/executed.txt"/>
  </logging>
</phpunit>

Without -vvv the error is:

In Assert.php line 995:
                                           
  Expected a value to be true. Got: false

I use the same command on different projects, and it works fine there. So I'm thinking maybe something is wrong in the generated coverage? Although they are both generated with same PHPUnit and XDebug version

@sanmai
Copy link
Member

sanmai commented Jan 17, 2021

Can you reproduce this issue with composer-installed Infection? E.g. composer require --dev infection/infection

@canvural
Copy link
Sponsor Author

@sanmai Yes. Installed 0.20.2@6035c1566af6a5a8d833a276351e5e18ed412305 from Composer. Ran it with ./vendor/bin/infection --coverage=tests/_reports "--initial-tests-php-options=-d memory_limit=-1"

This time a different error with stacktrace:

Stacktrace

PHPUnit version: 9.5.0

784 [============================] 1 min
In Assert.php line 2042:

[InvalidArgumentException]
Expected a value to be true. Got: false

Exception trace:
at /var/www/html/vendor/webmozart/assert/src/Assert.php:2042
Webmozart\Assert\Assert::reportInvalidArgument() at /var/www/html/vendor/webmozart/assert/src/Assert.php:619
Webmozart\Assert\Assert::true() at /var/www/html/vendor/infection/infection/src/TestFramework/Coverage/JUnit/JUnitTestFileDataProvider.php:122
Infection\TestFramework\Coverage\JUnit\JUnitTestFileDataProvider::createXPath() at /var/www/html/vendor/infection/infection/src/TestFramework/Coverage/JUnit/JUnitTestFileDataProvider.php:112
Infection\TestFramework\Coverage\JUnit\JUnitTestFileDataProvider->getXPath() at /var/www/html/vendor/infection/infection/src/TestFramework/Coverage/JUnit/JUnitTestFileDataProvider.php:65
Infection\TestFramework\Coverage\JUnit\JUnitTestFileDataProvider->getTestFileInfo() at /var/www/html/vendor/infection/infection/src/TestFramework/Coverage/JUnit/MemoizedTestFileDataProvider.php:60
Infection\TestFramework\Coverage\JUnit\MemoizedTestFileDataProvider->getTestFileInfo() at /var/www/html/vendor/infection/infection/src/TestFramework/Coverage/JUnit/JUnitTestExecutionInfoAdder.php:102
Infection\TestFramework\Coverage\JUnit\JUnitTestExecutionInfoAdder->createCompleteTestLocation() at /var/www/html/vendor/infection/infection/src/TestFramework/Coverage/JUnit/JUnitTestExecutionInfoAdder.php:89
Infection\TestFramework\Coverage\JUnit\JUnitTestExecutionInfoAdder->testExecutionInfoAdder() at /var/www/html/vendor/infection/infection/src/TestFramework/Coverage/UnionTraceProvider.php:71
Infection\TestFramework\Coverage\UnionTraceProvider->provideTraces() at n/a:n/a
iterator_to_array() at /var/www/html/vendor/infection/infection/src/IterableCounter.php:64
Infection\IterableCounter::bufferAndCountIfNeeded() at /var/www/html/vendor/infection/infection/src/Mutation/MutationGenerator.php:94
Infection\Mutation\MutationGenerator->generate() at n/a:n/a
iterator_to_array() at /var/www/html/vendor/infection/infection/src/IterableCounter.php:64
Infection\IterableCounter::bufferAndCountIfNeeded() at /var/www/html/vendor/infection/infection/src/Process/Runner/MutationTestingRunner.php:100
Infection\Process\Runner\MutationTestingRunner->run() at /var/www/html/vendor/infection/infection/src/Engine.php:171
Infection\Engine->runMutationAnalysis() at /var/www/html/vendor/infection/infection/src/Engine.php:111
Infection\Engine->execute() at /var/www/html/vendor/infection/infection/src/Command/RunCommand.php:260
Infection\Command\RunCommand->executeCommand() at /var/www/html/vendor/infection/infection/src/Command/BaseCommand.php:75
Infection\Command\BaseCommand->execute() at /var/www/html/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/html/vendor/symfony/console/Application.php:971
Symfony\Component\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:290
Symfony\Component\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:166
Symfony\Component\Console\Application->run() at /var/www/html/vendor/infection/infection/bin/infection:83

So I saw it mentioned JUnit. And I checked my phpunit.junit.xml file, and it was empty! 🤦‍♂️ I ran my test coverage again, generated phpunit.junit.xml correctly, then ran infection again. And now it worked.

My issue is solved. But maybe error handling around empty phpunit.junit.xml file could be improved? It was confusing to solve this.

@maks-rafalko
Copy link
Member

do you know the reason why phpunit.junit.xml was empty?

@canvural
Copy link
Sponsor Author

@maks-rafalko No, I'm not sure. I was running the code coverage during the morning. I had a couple of PHPUnit errors. Maybe it just created an empty file. Definitely not related to Infection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants