Make async test more robust

main
Jordi Boggiano 4 years ago
parent c46b75de81
commit c01e3bd2f0
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -119,10 +119,13 @@ class ProcessExecutorTest extends TestCase
{
$process = new ProcessExecutor($buffer = new BufferIO('', StreamOutput::VERBOSITY_DEBUG));
$process->enableAsync();
$start = microtime(true);
/** @var Promise $promise */
$promise = $process->executeAsync('echo foo');
$promise = $process->executeAsync('sleep 2');
$this->assertEquals(1, $process->countActiveJobs());
$promise->cancel();
$this->assertEquals(0, $process->countActiveJobs());
$end = microtime(true);
$this->assertTrue($end - $start < 0.5, 'Canceling took longer than it should, lasted '.($end - $start));
}
}

Loading…
Cancel
Save