1
0
mirror of https://github.com/danog/file.git synced 2024-11-30 04:19:39 +01:00

Use separate pool for each parallel test

Shutdown the pool after each test to avoid spawning many workers.
This commit is contained in:
Aaron Piotrowski 2017-05-17 22:59:17 -05:00
parent 32454e960b
commit 783ad03940
2 changed files with 32 additions and 2 deletions

View File

@ -2,12 +2,27 @@
namespace Amp\File\Test;
use Amp\Loop;
use Amp\Parallel\Worker\DefaultPool;
class ParallelDriverTest extends DriverTest {
/** @var \Amp\Parallel\Worker\Pool */
private $pool;
public function setUp() {
$this->pool = new DefaultPool;
$this->pool->start();
}
public function tearDown() {
Loop::run(function () {
yield $this->pool->shutdown();
});
}
protected function lRun(callable $cb) {
\Amp\Loop::run(function() use ($cb) {
\Amp\File\filesystem(new \Amp\File\ParallelDriver(new DefaultPool));
\Amp\File\filesystem(new \Amp\File\ParallelDriver($this->pool));
\Amp\Promise\rethrow(new \Amp\Coroutine($cb()));
});
}

View File

@ -2,12 +2,27 @@
namespace Amp\File\Test;
use Amp\Loop;
use Amp\Parallel\Worker\DefaultPool;
class ParallelHandleTest extends HandleTest {
/** @var \Amp\Parallel\Worker\Pool */
private $pool;
public function setUp() {
$this->pool = new DefaultPool;
$this->pool->start();
}
public function tearDown() {
Loop::run(function () {
yield $this->pool->shutdown();
});
}
protected function lRun(callable $cb) {
\Amp\Loop::run(function() use ($cb) {
\Amp\File\filesystem(new \Amp\File\ParallelDriver(new DefaultPool));
\Amp\File\filesystem(new \Amp\File\ParallelDriver($this->pool));
\Amp\Promise\rethrow(new \Amp\Coroutine($cb()));
});
}