From e6a5de671a2082d0ebbef90f68c64b74941db9d2 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Wed, 27 Dec 2017 12:17:35 -0600 Subject: [PATCH] Move GC test to ProcessPoolTest --- test/Worker/AbstractPoolTest.php | 20 -------------------- test/Worker/ProcessPoolTest.php | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/test/Worker/AbstractPoolTest.php b/test/Worker/AbstractPoolTest.php index c53df2e..0845d74 100644 --- a/test/Worker/AbstractPoolTest.php +++ b/test/Worker/AbstractPoolTest.php @@ -130,24 +130,4 @@ abstract class AbstractPoolTest extends TestCase { yield $pool->shutdown(); }); } - - public function testCleanGarbageCollection() { - // See https://github.com/amphp/parallel-functions/issues/5 - Loop::run(function () { - for ($i = 0; $i < 15; $i++) { - $pool = $this->createPool(32); - - $values = \range(1, 50); - $tasks = \array_map(function (int $value): Task { - return new TestTask($value); - }, $values); - - $promises = \array_map(function (Task $task) use ($pool): Promise { - return $pool->enqueue($task); - }, $tasks); - - $this->assertSame($values, yield $promises); - } - }); - } } diff --git a/test/Worker/ProcessPoolTest.php b/test/Worker/ProcessPoolTest.php index b21c268..f737952 100644 --- a/test/Worker/ProcessPoolTest.php +++ b/test/Worker/ProcessPoolTest.php @@ -2,10 +2,13 @@ namespace Amp\Parallel\Test\Worker; +use Amp\Loop; use Amp\Parallel\Worker\DefaultPool; use Amp\Parallel\Worker\Pool; +use Amp\Parallel\Worker\Task; use Amp\Parallel\Worker\WorkerFactory; use Amp\Parallel\Worker\WorkerProcess; +use Amp\Promise; /** * @group process @@ -19,4 +22,27 @@ class ProcessPoolTest extends AbstractPoolTest { return new DefaultPool($max, $factory); } + + /** + * @FIXME This test should be moved to AbstractPoolTest once the GC issues with pthreads are resolved. + */ + public function testCleanGarbageCollection() { + // See https://github.com/amphp/parallel-functions/issues/5 + Loop::run(function () { + for ($i = 0; $i < 15; $i++) { + $pool = $this->createPool(32); + + $values = \range(1, 50); + $tasks = \array_map(function (int $value): Task { + return new TestTask($value); + }, $values); + + $promises = \array_map(function (Task $task) use ($pool): Promise { + return $pool->enqueue($task); + }, $tasks); + + $this->assertSame($values, yield $promises); + } + }); + } }