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 -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	20 Jul 2009 23:59:05 -0000
@@ -30,8 +30,12 @@
 
   /**
    * 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 @@
    */
   public function __construct($test_id = NULL) {
     $this->testId = $test_id;
+    $this->timeLimit = variable_get('simpletest_time_limit', 180);
   }
 
   /**
Index: modules/simpletest/simpletest.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.pages.inc,v
retrieving revision 1.8
diff -u -r1.8 simpletest.pages.inc
--- modules/simpletest/simpletest.pages.inc	11 Jul 2009 06:14:48 -0000	1.8
+++ modules/simpletest/simpletest.pages.inc	20 Jul 2009 23:59:05 -0000
@@ -428,6 +428,13 @@
     '#description' => t('The verbose data will be printed along with the standard assertions. Useful for debugging.'),
     '#default_value' => variable_get('simpletest_verbose', TRUE),
   );
+  $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.'),
+    '#default_value' => variable_get('simpletest_time_limit', 180),
+    '#size' => 5,
+  );
 
   $form['httpauth'] = array(
     '#type' => 'fieldset',
Index: modules/simpletest/simpletest.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.install,v
retrieving revision 1.24
diff -u -r1.24 simpletest.install
--- modules/simpletest/simpletest.install	9 Jul 2009 10:21:14 -0000	1.24
+++ modules/simpletest/simpletest.install	20 Jul 2009 23:59:05 -0000
@@ -109,6 +109,7 @@
   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 @@
 
   $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 @@
   );
   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;
