Make async test more robust
parent
c46b75de81
commit
c01e3bd2f0
|
@ -119,10 +119,13 @@ class ProcessExecutorTest extends TestCase
|
||||||
{
|
{
|
||||||
$process = new ProcessExecutor($buffer = new BufferIO('', StreamOutput::VERBOSITY_DEBUG));
|
$process = new ProcessExecutor($buffer = new BufferIO('', StreamOutput::VERBOSITY_DEBUG));
|
||||||
$process->enableAsync();
|
$process->enableAsync();
|
||||||
|
$start = microtime(true);
|
||||||
/** @var Promise $promise */
|
/** @var Promise $promise */
|
||||||
$promise = $process->executeAsync('echo foo');
|
$promise = $process->executeAsync('sleep 2');
|
||||||
$this->assertEquals(1, $process->countActiveJobs());
|
$this->assertEquals(1, $process->countActiveJobs());
|
||||||
$promise->cancel();
|
$promise->cancel();
|
||||||
$this->assertEquals(0, $process->countActiveJobs());
|
$this->assertEquals(0, $process->countActiveJobs());
|
||||||
|
$end = microtime(true);
|
||||||
|
$this->assertTrue($end - $start < 0.5, 'Canceling took longer than it should, lasted '.($end - $start));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue