Skip to content

Commit

Permalink
Run tests twice, once with, and once without coverage
Browse files Browse the repository at this point in the history
We're doing this because certain tests have memory leaks only when code coverage is collected.
  • Loading branch information
WyriHaximus committed Feb 22, 2020
1 parent be2544a commit d10e897
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ install:
- composer install --no-interaction

script:
- vendor/bin/phpunit --coverage-text
- ./vendor/bin/phpunit -v
- ./vendor/bin/phpunit -v --coverage-text --coverage-clover=./build/logs/clover.xml
8 changes: 8 additions & 0 deletions tests/FunctionRejectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public function testWaitingForPromiseToRejectDoesNotLeaveGarbageCycles()
$this->markTestSkipped('Not supported on legacy Promise v1 API');
}

if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) {
$this->markTestSkipped('This test has memory leaks when code coverage is collected');
}

gc_collect_cycles();

$promise = Timer\reject(0.01, $this->loop);
Expand All @@ -68,6 +72,10 @@ public function testCancellingPromiseDoesNotLeaveGarbageCycles()
$this->markTestSkipped('Not supported on legacy Promise v1 API');
}

if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) {
$this->markTestSkipped('This test has memory leaks when code coverage is collected');
}

gc_collect_cycles();

$promise = Timer\reject(0.01, $this->loop);
Expand Down
8 changes: 8 additions & 0 deletions tests/FunctionResolveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public function testWaitingForPromiseToResolveDoesNotLeaveGarbageCycles()
$this->markTestSkipped('Not supported on legacy Promise v1 API');
}

if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) {
$this->markTestSkipped('This test has memory leaks when code coverage is collected');
}

gc_collect_cycles();

$promise = Timer\resolve(0.01, $this->loop);
Expand All @@ -90,6 +94,10 @@ public function testCancellingPromiseDoesNotLeaveGarbageCycles()
$this->markTestSkipped('Not supported on legacy Promise v1 API');
}

if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) {
$this->markTestSkipped('This test has memory leaks when code coverage is collected');
}

gc_collect_cycles();

$promise = Timer\resolve(0.01, $this->loop);
Expand Down
8 changes: 8 additions & 0 deletions tests/FunctionTimeoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ public function testWaitingForPromiseToResolveBeforeTimeoutDoesNotLeaveGarbageCy
$this->markTestSkipped('Not supported on legacy Promise v1 API');
}

if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) {
$this->markTestSkipped('This test has memory leaks when code coverage is collected');
}

gc_collect_cycles();

$promise = Timer\resolve(0.01, $this->loop);
Expand All @@ -194,6 +198,10 @@ public function testWaitingForPromiseToRejectBeforeTimeoutDoesNotLeaveGarbageCyc
$this->markTestSkipped('Not supported on legacy Promise v1 API');
}

if ($this->getTestResultObject()->getCollectCodeCoverageInformation() === true) {
$this->markTestSkipped('This test has memory leaks when code coverage is collected');
}

gc_collect_cycles();

$promise = Timer\reject(0.01, $this->loop);
Expand Down

0 comments on commit d10e897

Please sign in to comment.