From af7fa59e9b410d5ec23382d26763c74386e96962 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Sat, 1 Feb 2020 12:20:28 +0100 Subject: [PATCH 1/2] Test PHP 7.4 on Travis --- .travis.yml | 2 ++ tests/DeferredTest.php | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/.travis.yml b/.travis.yml index bd2ae443..ddac7a86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php: - 7.1 - 7.2 - 7.3 + - 7.4 - nightly # ignore errors, see below # lock distro so new future defaults will not break the build @@ -17,6 +18,7 @@ install: - composer install script: + - ./vendor/bin/phpunit -v - ./vendor/bin/phpunit -v --coverage-text --coverage-clover=./build/logs/clover.xml after_script: diff --git a/tests/DeferredTest.php b/tests/DeferredTest.php index 172cb246..861dd576 100644 --- a/tests/DeferredTest.php +++ b/tests/DeferredTest.php @@ -23,6 +23,10 @@ public function getPromiseTestAdapter(callable $canceller = null) /** @test */ public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithException() { + if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) { + $this->markTestSkipped('This test has memory leaks when code coverage is collected'); + } + gc_collect_cycles(); $deferred = new Deferred(function ($resolve, $reject) { $reject(new \Exception('foo')); @@ -36,6 +40,10 @@ public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithEx /** @test */ public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejectsWithException() { + if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) { + $this->markTestSkipped('This test has memory leaks when code coverage is collected'); + } + gc_collect_cycles(); $deferred = new Deferred(function ($resolve, $reject) { $reject(new \Exception('foo')); @@ -49,6 +57,10 @@ public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejects /** @test */ public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerHoldsReferenceAndExplicitlyRejectWithException() { + if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) { + $this->markTestSkipped('This test has memory leaks when code coverage is collected'); + } + gc_collect_cycles(); $deferred = new Deferred(function () use (&$deferred) { }); $deferred->reject(new \Exception('foo')); From 6ee24c2fcc7335cdb938d225b7ad2c4ee373e233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 4 Mar 2020 10:57:29 +0100 Subject: [PATCH 2/2] Clear garbage references twice before starting tests Clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on (`vendor/bin/phpunit --coverage-text`). --- .travis.yml | 1 - tests/DeferredTest.php | 16 ++++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index ddac7a86..12b6dd49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ install: - composer install script: - - ./vendor/bin/phpunit -v - ./vendor/bin/phpunit -v --coverage-text --coverage-clover=./build/logs/clover.xml after_script: diff --git a/tests/DeferredTest.php b/tests/DeferredTest.php index 861dd576..423625c3 100644 --- a/tests/DeferredTest.php +++ b/tests/DeferredTest.php @@ -23,10 +23,6 @@ public function getPromiseTestAdapter(callable $canceller = null) /** @test */ public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithException() { - if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) { - $this->markTestSkipped('This test has memory leaks when code coverage is collected'); - } - gc_collect_cycles(); $deferred = new Deferred(function ($resolve, $reject) { $reject(new \Exception('foo')); @@ -40,11 +36,9 @@ public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithEx /** @test */ public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejectsWithException() { - if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) { - $this->markTestSkipped('This test has memory leaks when code coverage is collected'); - } - gc_collect_cycles(); + gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on + $deferred = new Deferred(function ($resolve, $reject) { $reject(new \Exception('foo')); }); @@ -57,11 +51,9 @@ public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejects /** @test */ public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerHoldsReferenceAndExplicitlyRejectWithException() { - if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) { - $this->markTestSkipped('This test has memory leaks when code coverage is collected'); - } - gc_collect_cycles(); + gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on + $deferred = new Deferred(function () use (&$deferred) { }); $deferred->reject(new \Exception('foo')); unset($deferred);