Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Unittesting a Symfony 4.2 process runs infinite loop (than times out), wihout unittest it works fine

$
0
0

Lets say I have the following Symfony 4 command:

class Command1  extends Command {
    protected static $defaultName = 'app:command1';

    protected function execute(InputInterface $input, OutputInterface $output){
        $process = new Process('bin/console list', getcwd());
        $process->start(); // or even $process->run() does not matter if its async or not
        // ... where we handle if its finished, etc...
    }
}

If I simply call bin/console app:command1 it will return the expected command list. Basically works as I expect.

But if I have a phpunit test which uses the Symfony\Component\Console\Application::run() to start this command, I end up in an "infinite loop" (well, actually not, it times out after 60 sec) in the Symfony\Component\Process::wait() in the

do {
    $this->checkTimeout();
    $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
    $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
} while ($running);

where the $this->processPipes->areOpen() will be always open.

It seems to me, if I use any Symfony console command in a Process through phpunit, there will be always two pipes open like these:

1 = {resource} resource id='x' type='stream'
2 = {resource} resource id='z' type='stream'

but I don't know what are these actually. I also saw in htop, that the start()'s proc_open actually starts up a new process, but it just hangs (does absolutely nothing, cant even debug it), until times out. Nothing in error logs (other than the timeout).


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>