Skip to content

Commit b571095

Browse files
committed
adjust unit test settings for time limits
Some tests were testing a bug that caused an infinite loop. Annotate those tests with large, small annotations. Turn on enforceTimeLimit, failOnWarning and failOnRisky so that the annotations are enforced when unit tests are run. Add phpunit/php-invoker to the composer require-dev becaause this is required to make the enforceTimeLimit setting effective.
1 parent 7e48c32 commit b571095

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"require-dev" : {
4040
"friendsofphp/php-cs-fixer": "~2.17.1",
4141
"phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0",
42+
"phpunit/php-invoker" : "^2.0 || ^3.1",
4243
"phpstan/phpstan": "^0.12"
4344
},
4445
"suggest" : {

tests/VObject/Component/VCalendarTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ public function testBrokenEventExpand()
350350
);
351351
}
352352

353+
/**
354+
* This test used to induce an infinite loop.
355+
* The "medium" annotation means that phpunit will fail the
356+
* test if it takes longer than a default of 10 seconds.
357+
*
358+
* @medium
359+
*/
353360
public function testEventExpandYearly()
354361
{
355362
$input = 'BEGIN:VCALENDAR

tests/VObject/Recur/RRuleIteratorTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,13 @@ public function testMinusFifthThursday()
892892
);
893893
}
894894

895+
/**
896+
* This test can take some seconds to complete.
897+
* The "large" annotation means phpunit will let it run for
898+
* up to 60 seconds by default.
899+
*
900+
* @large
901+
*/
895902
public function testNeverEnding()
896903
{
897904
$this->parse(

tests/phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
convertWarningsToExceptions="true"
77
beStrictAboutTestsThatDoNotTestAnything="true"
88
beStrictAboutOutputDuringTests="true"
9+
failOnRisky="true"
10+
failOnWarning="true"
11+
enforceTimeLimit="true"
912
>
1013
<testsuites>
1114
<testsuite name="Sabre\VObject">

0 commit comments

Comments
 (0)