Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.133
diff -u -p -r1.133 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	3 Aug 2009 22:18:59 -0000	1.133
+++ modules/simpletest/drupal_web_test_case.php	3 Aug 2009 22:58:36 -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.25
diff -u -p -r1.25 simpletest.install
--- modules/simpletest/simpletest.install	22 Jul 2009 04:45:35 -0000	1.25
+++ modules/simpletest/simpletest.install	3 Aug 2009 22:58:36 -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');
@@ -132,6 +133,7 @@ function simpletest_requirements($phase)
   $has_curl = function_exists('curl_init');
   $has_hash = function_exists('hash_hmac');
   $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'),
@@ -156,7 +158,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.10
diff -u -p -r1.10 simpletest.pages.inc
--- modules/simpletest/simpletest.pages.inc	29 Jul 2009 06:39:34 -0000	1.10
+++ modules/simpletest/simpletest.pages.inc	3 Aug 2009 22:58:36 -0000
@@ -430,6 +430,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',
@@ -449,3 +456,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
