Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make timeouts configurable.

  • Loading branch information...
commit a9aa2b57cf1efa74b1be5b6f053688e43afb1cd6 1 parent 70e0629
@sebastianbergmann authored
View
30 PHPUnit/TextUI/TestRunner.php
@@ -295,6 +295,18 @@ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
if ($arguments['strict']) {
$result->strictMode(TRUE);
+
+ $result->setTimeoutForSmallTests(
+ $arguments['timeoutForSmallTests']
+ );
+
+ $result->setTimeoutForMediumTests(
+ $arguments['timeoutForMediumTests']
+ );
+
+ $result->setTimeoutForLargeTests(
+ $arguments['timeoutForLargeTests']
+ );
}
$suite->run(
@@ -540,6 +552,21 @@ protected function handleConfiguration(array &$arguments)
$arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
}
+ if (isset($phpunitConfiguration['timeoutForSmallTests']) &&
+ !isset($arguments['timeoutForSmallTests'])) {
+ $arguments['timeoutForSmallTests'] = $phpunitConfiguration['timeoutForSmallTests'];
+ }
+
+ if (isset($phpunitConfiguration['timeoutForMediumTests']) &&
+ !isset($arguments['timeoutForMediumTests'])) {
+ $arguments['timeoutForMediumTests'] = $phpunitConfiguration['timeoutForMediumTests'];
+ }
+
+ if (isset($phpunitConfiguration['timeoutForLargeTests']) &&
+ !isset($arguments['timeoutForLargeTests'])) {
+ $arguments['timeoutForLargeTests'] = $phpunitConfiguration['timeoutForLargeTests'];
+ }
+
if (isset($phpunitConfiguration['strict']) &&
!isset($arguments['strict'])) {
$arguments['strict'] = $phpunitConfiguration['strict'];
@@ -747,6 +774,9 @@ protected function handleConfiguration(array &$arguments)
$arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE;
$arguments['stopOnIncomplete'] = isset($arguments['stopOnIncomplete']) ? $arguments['stopOnIncomplete'] : FALSE;
$arguments['stopOnSkipped'] = isset($arguments['stopOnSkipped']) ? $arguments['stopOnSkipped'] : FALSE;
+ $arguments['timeoutForSmallTests'] = isset($arguments['timeoutForSmallTests']) ? $arguments['timeoutForSmallTests'] : 1;
+ $arguments['timeoutForMediumTests'] = isset($arguments['timeoutForMediumTests']) ? $arguments['timeoutForMediumTests'] : 10;
+ $arguments['timeoutForLargeTests'] = isset($arguments['timeoutForLargeTests']) ? $arguments['timeoutForLargeTests'] : 60;
$arguments['strict'] = isset($arguments['strict']) ? $arguments['strict'] : FALSE;
$arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE;
View
36 PHPUnit/Util/Configuration.php
@@ -67,6 +67,9 @@
* stopOnIncomplete="false"
* stopOnSkipped="false"
* testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
+ * timeoutForSmallTests="1"
+ * timeoutForMediumTests="10"
+ * timeoutForLargeTests="60"
* strict="false"
* verbose="false">
* <testsuites>
@@ -661,6 +664,24 @@ public function getPHPUnitConfiguration()
);
}
+ if ($root->hasAttribute('timeoutForSmallTests')) {
+ $result['timeoutForSmallTests'] = $this->getInteger(
+ (string)$root->getAttribute('timeoutForSmallTests'), 1
+ );
+ }
+
+ if ($root->hasAttribute('timeoutForMediumTests')) {
+ $result['timeoutForMediumTests'] = $this->getInteger(
+ (string)$root->getAttribute('timeoutForMediumTests'), 10
+ );
+ }
+
+ if ($root->hasAttribute('timeoutForLargeTests')) {
+ $result['timeoutForLargeTests'] = $this->getInteger(
+ (string)$root->getAttribute('timeoutForLargeTests'), 60
+ );
+ }
+
if ($root->hasAttribute('strict')) {
$result['strict'] = $this->getBoolean(
(string)$root->getAttribute('strict'), FALSE
@@ -867,6 +888,21 @@ protected function getBoolean($value, $default)
}
/**
+ * @param string $value
+ * @param boolean $default
+ * @return boolean
+ * @since Method available since Release 3.6.0
+ */
+ protected function getInteger($value, $default)
+ {
+ if (is_numeric($value)) {
+ return (int)$value;
+ }
+
+ return $default;
+ }
+
+ /**
* @param string $query
* @return array
* @since Method available since Release 3.2.3
View
5 Tests/Util/ConfigurationTest.php
@@ -300,7 +300,10 @@ public function testPHPUnitConfigurationIsReadCorrectly()
'stopOnFailure' => FALSE,
'strict' => FALSE,
'testSuiteLoaderClass' => 'PHPUnit_Runner_StandardTestSuiteLoader',
- 'verbose' => FALSE
+ 'verbose' => FALSE,
+ 'timeoutForSmallTests' => 1,
+ 'timeoutForMediumTests' => 10,
+ 'timeoutForLargeTests' => 60
),
$this->configuration->getPHPUnitConfiguration()
);
View
3  Tests/_files/configuration.xml
@@ -13,6 +13,9 @@
printerClass="PHPUnit_TextUI_ResultPrinter"
stopOnFailure="false"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
+ timeoutForSmallTests="1"
+ timeoutForMediumTests="10"
+ timeoutForLargeTests="60"
strict="false"
verbose="false">
<testsuites>
Please sign in to comment.
Something went wrong with that request. Please try again.