Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.127
diff -u -p -r1.127 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	15 Jul 2009 02:08:41 -0000	1.127
+++ modules/simpletest/drupal_web_test_case.php	21 Jul 2009 05:12:23 -0000
@@ -30,8 +30,12 @@ abstract class DrupalTestCase {
 
   /**
    * Time limit for the test.
+   *
+   * The value is initialized in the constructor from a settings variable.
+   *
+   * @var integer
    */
-  protected $timeLimit = 180;
+  protected $timeLimit;
 
   /**
    * Current results of this test case.
@@ -69,6 +73,7 @@ abstract class DrupalTestCase {
    */
   public function __construct($test_id = NULL) {
     $this->testId = $test_id;
+    $this->timeLimit = variable_get('simpletest_time_limit', 180);
   }
 
   /**
Index: modules/simpletest/simpletest.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.install,v
retrieving revision 1.24
diff -u -p -r1.24 simpletest.install
--- modules/simpletest/simpletest.install	9 Jul 2009 10:21:14 -0000	1.24
+++ modules/simpletest/simpletest.install	21 Jul 2009 05:12:23 -0000
@@ -109,6 +109,7 @@ function simpletest_uninstall() {
   variable_del('simpletest_password');
   variable_del('simpletest_clear_results');
   variable_del('simpletest_verbose');
+  variable_del('simpletest_time_limit');
 
   // Uninstall schema.
   drupal_uninstall_schema('simpletest');
@@ -131,6 +132,7 @@ function simpletest_requirements($phase)
 
   $has_curl = function_exists('curl_init');
   $has_domdocument = class_exists('DOMDocument');
+  $can_set_time_limit = !ini_get('safe_mode') && strpos(ini_get('disable_functions'), 'set_time_limit') === FALSE;
 
   $requirements['curl'] = array(
     'title' => $t('cURL'),
@@ -147,7 +149,16 @@ function simpletest_requirements($phase)
   );
   if (!$has_domdocument) {
     $requirements['php_domdocument']['severity'] = REQUIREMENT_ERROR;
-    $requirements['php_domdocument']['description'] =t('SimpleTest requires the DOMDocument class to be available. Please check the configure command at the <a href="@link-phpinfo">PHP info page</a>.', array('@link-phpinfo' => url('admin/reports/status/php')));
+    $requirements['php_domdocument']['description'] = $t('SimpleTest requires the DOMDocument class to be available. Please check the configure command at the <a href="@link-phpinfo">PHP info page</a>.', array('@link-phpinfo' => url('admin/reports/status/php')));
+  }
+
+  $requirements['php_set_time_limit'] = array(
+    'title' => $t('Can call %f', array('%f' => 'set_time_limit()')),
+    'value' => $can_set_time_limit ? $t('Yes') : $t('No'),
+  );
+  if (!$can_set_time_limit) {
+    $requirements['php_set_time_limit']['severity'] = REQUIREMENT_ERROR;
+    $requirements['php_set_time_limit']['description'] = $t('Simpletest cannot run in safe_mode or with function set_time_limit() disable. Correct this in php.ini');
   }
 
   return $requirements;
Index: modules/simpletest/simpletest.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.pages.inc,v
retrieving revision 1.9
diff -u -p -r1.9 simpletest.pages.inc
--- modules/simpletest/simpletest.pages.inc	21 Jul 2009 01:48:08 -0000	1.9
+++ modules/simpletest/simpletest.pages.inc	21 Jul 2009 05:12:23 -0000
@@ -428,6 +428,13 @@ function simpletest_settings_form(&$form
     '#description' => t('The verbose data will be printed along with the standard assertions. Useful for debugging.'),
     '#default_value' => variable_get('simpletest_verbose', FALSE),
   );
+  $form['general']['simpletest_time_limit'] = array(
+    '#type' => 'textfield',
+    '#title' => t('PHP script execution time limit'),
+    '#description' => t('Simpletest calls set_time_limit() with this value to increase the PHP script execution time limit to avoid possible timeout error, adjust this value upward if timeout error occur during test run. Set to zero for no limit.'),
+    '#default_value' => variable_get('simpletest_time_limit', 180),
+    '#size' => 5,
+  );
 
   $form['httpauth'] = array(
     '#type' => 'fieldset',
@@ -447,3 +454,11 @@ function simpletest_settings_form(&$form
 
   return system_settings_form($form);
 }
+
+
+function simpletest_settings_form_validate($form, $form_state) {
+  $value = $form_state['values']['simpletest_time_limit'];
+  if ($value !== (string)(int)$value || $value < 0) {
+    form_error($form['general']['simpletest_time_limit'], t('Must be an integer >= 0.'));
+  }
+}
\ No newline at end of file
