global $UNITTEST;
$UNITTEST = new stdClass();
+// This limit is the time allowed per individual test function. Please do not
+// increase this value. If you get a PHP time limit when running unit tests,
+// find the unit test which is running slowly, and either make it faster,
+// split it into multiple tests, or call set_time_limit within that test.
+define('TIME_ALLOWED_PER_UNIT_TEST', 60);
+
// Print the header.
$strtitle = get_string('unittests', 'simpletest');
$title = get_string('moodleunittests', 'simpletest', $displaypath);
}
echo $OUTPUT->heading($title);
- set_time_limit(300); // 5 mins
$test->run($reporter);
}
* modified run() in test_case.php - skipping tests that need fake db if prefix not set
* search replace deprecated "=& new"
* MDL-20876 - replaced deprecated split() with explode()
+ * test_case.php - added TIME_ALLOWED_PER_UNIT_TEST constant which
+ resets php time limit for each test function - MDL-24909. Marked with
+ comments (replace existing per-class hack in test_case.php).
-skodak, Tim
+skodak, Tim, sammarshall
$reporter->paintCaseStart($this->getLabel());
$started = true;
}
+//moodlefix begins
+ if (defined('TIME_ALLOWED_PER_UNIT_TEST')) {
+ set_time_limit(TIME_ALLOWED_PER_UNIT_TEST);
+ }
+//moodlefix ends
$invoker = &$this->_reporter->createInvoker($this->createInvoker());
$invoker->before($method);
$invoker->invoke($method);
$reporter->paintSkip("Unit test \"{$class}\" of type UnitTestCaseUsingDatabase skipped. Must define different, non-conflicting \$CFG->unittestprefix to be runnable.");
continue;
}
- if ($currenttl = @ini_get('max_execution_time')) {
- @ini_set('max_execution_time', $currenttl);
- }
// moodle hack end
$test = new $class();
$test->run($reporter);