1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Make async test more robust

This commit is contained in:
Jordi Boggiano 2020-10-16 11:23:03 +02:00
parent c46b75de81
commit c01e3bd2f0
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC

View file

@ -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));
}
}