Skip to content

Commit 4b69575

Browse files
committed
Run tests twice, once with, and once without coverage
We're doing this because certain tests have memory leaks only when code coverage is collected.
1 parent 38af4ad commit 4b69575

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ install:
1818
- composer install
1919

2020
script:
21-
- ./vendor/bin/phpunit -v --coverage-text --coverage-clover=./build/logs/clover.xml
21+
- ./vendor/bin/phpunit -v
22+
- XDEBUG_CODE_COVERAGE_IS_COLLECTED=yes ./vendor/bin/phpunit -v --coverage-text --coverage-clover=./build/logs/clover.xml
2223

2324
after_script:
2425
- if [ -f ./build/logs/clover.xml ]; then travis_retry composer require php-coveralls/php-coveralls --no-interaction --update-with-dependencies; fi

tests/DeferredTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public function getPromiseTestAdapter(callable $canceller = null)
2323
/** @test */
2424
public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithException()
2525
{
26+
if (getenv('XDEBUG_CODE_COVERAGE_IS_COLLECTED')) {
27+
$this->markTestSkipped('This test has memory leaks when code coverage is collected');
28+
}
29+
2630
gc_collect_cycles();
2731
$deferred = new Deferred(function ($resolve, $reject) {
2832
$reject(new \Exception('foo'));
@@ -36,6 +40,10 @@ public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerRejectsWithEx
3640
/** @test */
3741
public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejectsWithException()
3842
{
43+
if (getenv('XDEBUG_CODE_COVERAGE_IS_COLLECTED')) {
44+
$this->markTestSkipped('This test has memory leaks when code coverage is collected');
45+
}
46+
3947
gc_collect_cycles();
4048
$deferred = new Deferred(function ($resolve, $reject) {
4149
$reject(new \Exception('foo'));
@@ -49,6 +57,10 @@ public function shouldRejectWithoutCreatingGarbageCyclesIfParentCancellerRejects
4957
/** @test */
5058
public function shouldRejectWithoutCreatingGarbageCyclesIfCancellerHoldsReferenceAndExplicitlyRejectWithException()
5159
{
60+
if (getenv('XDEBUG_CODE_COVERAGE_IS_COLLECTED')) {
61+
$this->markTestSkipped('This test has memory leaks when code coverage is collected');
62+
}
63+
5264
gc_collect_cycles();
5365
$deferred = new Deferred(function () use (&$deferred) { });
5466
$deferred->reject(new \Exception('foo'));

0 commit comments

Comments
 (0)