php-git-hooks icon indicating copy to clipboard operation
php-git-hooks copied to clipboard

The process "php bin/phpunit " exceeded the timeout of 60 seconds.

Open mazhack opened this issue 10 years ago • 6 comments

Hi, when i run phpunit alone

$ bin/phpunit
PHPUnit 5.5.5 by Sebastian Bergmann and contributors.

...............................................................  63 / 232 ( 27%)
............................................................... 126 / 232 ( 54%)
............................................................... 189 / 232 ( 81%)
...........................................                     232 / 232 (100%)

Time: 1,12 minutes, Memory: 27,00MB

OK (232 tests, 488 assertions)

on commit:

$ git commit
Pre-Commit tool
Checking composer files...........................0K
Checking json files...............................0K
Running PHPLINT...................................0K
Checking PSR0 code style with PHP-CS-FIXER........0K
Checking PSR1 code style with PHP-CS-FIXER........0K
Checking PSR2 code style with PHP-CS-FIXER........0K
Running unit tests................................
PHPUnit 5.5.5 by Sebastian Bergmann and contributors.

...............................................................  63 / 232 ( 27%)
............................................................... 126 / 232 ( 54%)
.........................

  [Symfony\Component\Process\Exception\ProcessTimedOutException]      
  The process "php bin/phpunit " exceeded the timeout of 60 seconds.  

How to set timeout gt 60 seconds?

Thank you!!

mazhack avatar Sep 22 '16 22:09 mazhack

Wow. You have heavy unit tests. I'm not sure, but maybe you can change timeout value in your cli/php.ini file.

bruli avatar Sep 23 '16 06:09 bruli

Hi, thanks for the answer, I modify the php.ini and does not work. I found the solution, is just add the line $process->setTimeout(0); to the PhpUnitProcessor class.

<?php

namespace PhpGitHooks\Module\PhpUnit\Infrastructure\Tool;

use PhpGitHooks\Module\PhpUnit\Model\PhpUnitProcessorInterface;
use Symfony\Component\Process\Process;

class PhpUnitProcessor extends AbstractPhpUnitProcessor implements PhpUnitProcessorInterface
{
    /**
     * @param $options
     *
     * @return bool
     */
    public function process($options)
    {
        $tool = sprintf('php %s %s', $this->toolPathFinder->find('phpunit'), $options);

        $process = new Process($tool);
        $process->setTimeout(0);

        return $this->runProcess($process);
    }
}

The \Symfony\Component\Process\Process define 60 secs for timeout by default

mazhack avatar Sep 23 '16 15:09 mazhack

Ok. Maybe there a better solution. I can review it.

bruli avatar Sep 23 '16 15:09 bruli

Has any proper solution been already found? When running with coverage even smaller test units would take more than 60 seconds.

aftabnaveed avatar Apr 27 '18 15:04 aftabnaveed

I think this issue deserves to be re-opened. I am not sure if this is a better idea but we can either pass the config in $options array or add an optional argument such as $config to the process method to pass configuration values. Or may be a helper method that we can add to the process class?

aftabnaveed avatar Sep 17 '18 07:09 aftabnaveed

composer.json

"config": {
        "process-timeout": 0
    }

robsontenorio avatar May 05 '20 10:05 robsontenorio