dongpu6141 2017-08-14 21:12
浏览 90
已采纳

PHPUnit在空缓存上运行超时

I'm trying to create a build process using phing. During this process I want to run the composer install script and phpunit, which is installed by composer

Inside my buildfile I have 2 targets.

<target name="composer">
    <composer command="install" composer="./composer.phar" />
    <autoloader autoloaderpath="./vendor/autoload.php" />
</target>
<target name="phpunit" depends="composer">
    <if>
        <os family="windows" />
        <then>
            <property name="phpunit.executable" value="phpunit.bat" />
        </then>
        <else>
            <property name="phpunit.executable" value="phpunit" />
        </else>
    </if>
    <exec executable="vendor/bin/${phpunit.executable}"
      dir="${project.basedir}" level="debug"
      returnProperty="phpunit.return">
        <arg line="--configuration" />
        <arg file="${project.basedir}/phpunit.xml" />
    </exec>
</target>

The composer.phar and phpunit.xml are in my project base. Now if I run the phpunit target I can see that the dependencies are checked and installed if needed. But PHPUnit only returns

PHPUnit 5.7.21 by Sebastian Bergmann and contributors.

and that is it. No tests are actually run. It seems like the configuration file is never read.

If I remove the depends from the phpunit target and run then, the tests are actually completed and logs and coverage report created. I'm using exec instead of the phpunit task because phings code coverage seems to have trouble with the backslashes in namespaces.

This is actually a Symfony project and calling

bin/console cache:warmup -e test

fixes the problem

Though calling PHPUnit from command line after composer install does actually run the tests.

Is there anywhere in phing or PHPUnit where I can change that timeout? The max execution time for php is set to 0.

  • 写回答

2条回答 默认 最新

  • dongru2019 2017-08-16 13:56
    关注

    How about adjusting build.xml to create a task to warm up the cache:

    <target name="cache-warmup">
        <exec command="bin/console cache:warmup -e test" />
    </target> 
    

    and then have the phpunit task also depend on that task:

    <target name="phpunit" depends="composer cache-warmup">
        ...
    </target> 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab