首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >phpdbg在感染情况下进行突变测试时达到内存限制

phpdbg在感染情况下进行突变测试时达到内存限制
EN

Stack Overflow用户
提问于 2019-06-10 15:42:51
回答 2查看 507关注 0票数 0

在尝试使用phpdbg运行感染测试时,我一直收到内存耗尽错误。我试过设置-d memory_limit,但似乎被忽略了。

以下是一些示例输出:

代码语言:javascript
复制
$ phpdbg -qrr -d memory_limit=1G vendor/bin/infection
You are running Infection with phpdbg enabled.
     ____      ____          __  _
    /  _/___  / __/__  _____/ /_(_)___  ____
    / // __ \/ /_/ _ \/ ___/ __/ / __ \/ __ \
  _/ // / / / __/  __/ /__/ /_/ / /_/ / / / /
 /___/_/ /_/_/  \___/\___/\__/_/\____/_/ /_/

Running initial test suite...

PHPUnit version: 7.5.11

    4 [============================]  1 sec

 [ERROR] Project tests must be in a passing state before running Infection.

         Infection runs the test suite in a RANDOM order. Make sure your tests do not have hidden dependencies.

         You can add these attributes to `phpunit.xml` to check it: <phpunit executionOrder="random"
         resolveDependencies="true" ...

         If you don't want to let Infection run tests in a random order, set the `executionOrder` to some value, for
         example <phpunit executionOrder="default"

         Check the executed command to identify the problem: '/usr/local/Cellar/php@7.2/7.2.18/bin/phpdbg' '-qrr'
         '~/Project/vendor/phpunit/phpunit/phpunit' '--configuration'
         '/var/folders/05/qbcbz9cn08jdty7r35dwkgdm0000gn/T/infection/phpunitConfiguration.initial.infection.xml'

         PHPUnit reported an exit code of 255.

         Refer to the PHPUnit's output below:

         STDOUT:

         PHPUnit 7.5.11 by Sebastian Bergmann and contributors.

         Random seed:   1560152243

         [PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in
         ~/Project/vendor/sebastian/exporter/src/Exporter.php on line
         219]
         [PHP Stack trace:]
         [PHP   1. {main}()
         ~/Project/vendor/phpunit/phpunit/phpunit:0]

使用我的infection.json.dist文件:

代码语言:javascript
复制
{
    "timeout": 10,
    "source": {
        "directories": [
            "src"
        ]
    },
    "logs": {
        "text": "infection.log"
    },
    "mutators": {
        "@default": true
    }
}
EN

回答 2

Stack Overflow用户

发布于 2019-06-10 16:12:41

您希望在开发环境的php.ini配置文件中包含memory_limit=-1

票数 0
EN

Stack Overflow用户

发布于 2019-07-14 12:08:10

您可以预先收集覆盖范围,然后将其提供给感染。

代码语言:javascript
复制
vendor/bin/phpunit --coverage-xml=build/logs/coverage-xml \
                   --log-junit=build/logs/junit.xml
vendor/bin/infection --coverage=build/logs --show-mutations

由于您不会同时运行感染和PHPUnit,因此可以完全避免内存限制问题。如果没有,使用更高的内存限制运行这两个程序中的任何一个都应该很容易:

代码语言:javascript
复制
php -d memory_limit=-1 vendor/bin/...

通过这种方式,您还可以在修复测试后重新运行感染,以查看您是否杀死了突变,而不需要重新收集覆盖数据。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56522423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档