Running just the Simpletest testcase:

An error occurred.
Path: /batch?id=3&op=do
Message:
Fatal error: Maximum execution time of 180 seconds exceeded in C:\drupal\drupal-HEAD\modules\simpletest\drupal_web_test_case.php on line 1269


Call Stack:
0.0008 75240 1. {main}() C:\drupal\drupal-HEAD\index.php:0
0.3171 12486688 2. menu_execute_active_handler() C:\drupal\drupal-HEAD\index.php:22
0.3332 13191864 3. call_user_func_array() C:\drupal\drupal-HEAD\includes\menu.inc:402
0.3332 13191864 4. system_batch_page() C:\drupal\drupal-HEAD\includes\menu.inc:0
0.3376 13300656 5. _batch_page() C:\drupal\drupal-HEAD\modules\system\system.admin.inc:1829
0.3396 13309104 6. _batch_do() C:\drupal\drupal-HEAD\includes\batch.inc:63
0.3396 13309448 7. _batch_process() C:\drupal\drupal-HEAD\includes\batch.inc:141
0.3397 13314664 8. call_user_func_array() C:\drupal\drupal-HEAD\includes\batch.inc:245
0.3397 13314664 9. _simpletest_batch_operation() C:\drupal\drupal-HEAD\includes\batch.inc:0
0.3533 14107144 10. DrupalTestCase->run() C:\drupal\drupal-HEAD\modules\simpletest\simpletest.module:170
133.9673 35767752 11. SimpleTestFunctionalTest->testWebTestRunner() C:\drupal\drupal-HEAD\modules\simpletest\drupal_web_test_case.php:398
252.5074 36021608 12. DrupalWebTestCase->drupalPost() C:\drupal\drupal-HEAD\modules\simpletest\simpletest.test:91
254.0652 35811144 13. DrupalWebTestCase->checkForMetaRefresh() C:\drupal\drupal-HEAD\modules\simpletest\drupal_web_test_case.php:1442
254.1154 35813192 14. DrupalWebTestCase->drupalGet() C:\drupal\drupal-HEAD\modules\simpletest\drupal_web_test_case.php:1476
254.1156 35813824 15. DrupalWebTestCase->curlExec() C:\drupal\drupal-HEAD\modules\simpletest\drupal_web_test_case.php:1348
254.1157 35815176 16. curl_exec() C:\drupal\drupal-HEAD\modules\simpletest\drupal_web_test_case.php:1247
373.6762 35807072 17. DrupalWebTestCase->curlHeaderCallback() C:\drupal\drupal-HEAD\modules\simpletest\drupal_web_test_case.php:0

in my php.ini,

max_execution_time = 3600

So I don't understand where this 180 seconds come from.

Comments

boombatower’s picture

Status: Active » Postponed (maintainer needs more info)

Since we have had issues with tests timeing out they set the timeout themseleves

The default is:

  /**
   * Time limit for the test.
   */
  protected $timeLimit = 180;

and in DrupalWebTestCase::setUp()

set_time_limit($this->timeLimit);

Seems like your machine is taking longer than usual, could be CPU speed or something related to configuration.

mattyoung’s picture

On my laptop, I need at least 300 for the Simpletest testcase to get through. So 180 is not enough for me.

The test takes 10 minutes to run.

How about setting this to a much higher value? This is for development only so it shouldn't matter.

boombatower’s picture

Seems reasonable, perhaps even a setting on setting page. Since it takes no where near that long to run on my machine I would rather it detect it quicker.

mattyoung’s picture

>Seems reasonable, perhaps even a setting on setting page

I think a setting value would be ideal. If possible, you can even set an error/exception handler to catch time out and direct the user to increase the value?

additionally, in simpletest_requirement() add:

if (ini_get('safe_mode') || strpos(ini_get('disable_functions'), 'set_time_limit') !== FALSE) {
     $requirements['php_set_time_limit']['serverity'] = 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');
}
boombatower’s picture

Status: Postponed (maintainer needs more info) » Active

Right, this just needs a patch.

mattyoung’s picture

Status: Active » Needs review
StatusFileSize
new2.58 KB

Here is a patch

1. add settings value for set_time_limit()
2. add requirements check for safe_mode or set_time_limit() disable
3. fix a little error in simpletest_requirements(), it was calling t() instead, it should be $t().

boombatower’s picture

Category: bug » feature
StatusFileSize
new3.99 KB

Re-rolled per: http://drupal.org/patch and cleaned up documentation.

mattyoung’s picture

StatusFileSize
new4.75 KB

add form validation for simpletest_time_limit in case some one enter something crazy

Status: Needs review » Needs work

The last submitted patch failed testing.

mattyoung’s picture

Status: Needs work » Needs review
StatusFileSize
new20.6 KB

Re-roll patch

boombatower’s picture

Patch looks a bit wacky since there is double line spacing. I haven't look at it in detail.

mattyoung’s picture

I just update to latest HEAD and re-roll the patch. Could it be problem with LF/CR mix up? I see every line is replace with exactly the same but with ^M at the end.

mattyoung’s picture

StatusFileSize
new4.8 KB

Re-roll pactch. I made sure the files use unix eol style. I check the patch and it look okay to me.

boombatower’s picture

Status: Needs review » Needs work
+
+
+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

Should be end of line...needs documentation...and remove extra blank line from above.

Otherwise looks fine.

mattyoung’s picture

StatusFileSize
new4.9 KB

Re-roll patch per instruction in previous message

mattyoung’s picture

Status: Needs work » Needs review

forgot to change status.

boombatower’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new4.82 KB
Simpletest calls set_time_limit() with this value to increase the PHP script exe

to

Simpletest calls set_time_limit() with this value to set the PHP script exe

I tested this with a value of 1 and it timedout....so looks good.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
+++ modules/simpletest/simpletest.pages.inc	4 Aug 2009 02:26:50 -0000
@@ -449,3 +456,15 @@
+ * Validate settings form value 'simpletest_time_limit' is an integer >= 0
+ * to prevent user from entering invalid value.

Shorten so fits into one line, or add one-line summary.

+++ modules/simpletest/simpletest.pages.inc	4 Aug 2009 02:26:50 -0000
@@ -449,3 +456,15 @@
+  if ($value !== (string)(int)$value || $value < 0) {

What is that weird $value !== (string)(int)$value stuff? Isn't it enough to cast $value to an integer and ensure it's not < 0?

If not, let's comment this because it's very weird.

+++ modules/simpletest/simpletest.install	4 Aug 2009 02:26:50 -0000
@@ -132,6 +133,7 @@
+  $can_set_time_limit = !ini_get('safe_mode') && strpos(ini_get('disable_functions'), 'set_time_limit') === FALSE;

Is checking for function_exists('set_time_limit') not sufficient here?

+++ modules/simpletest/simpletest.install	4 Aug 2009 02:26:50 -0000
@@ -156,7 +158,16 @@
+    $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');

disabled. php.ini should be followed by a period since it ends the sentence.

Beer-o-mania starts in 23 days! Don't drink and patch.

mattyoung’s picture

Assigned: Unassigned » mattyoung
Status: Needs work » Needs review
StatusFileSize
new5.26 KB
+++ modules/simpletest/simpletest.pages.inc 4 Aug 2009 02:26:50 -0000
@@ -449,3 +456,15 @@
+ * Validate settings form value 'simpletest_time_limit' is an integer >= 0
+ * to prevent user from entering invalid value.

>
>Shorten so fits into one line, or add one-line summary.

Okay.

+++ modules/simpletest/simpletest.pages.inc 4 Aug 2009 02:26:50 -0000
@@ -449,3 +456,15 @@
+  if ($value !== (string)(int)$value || $value < 0) {

>
>What is that weird $value !== (string)(int)$value stuff? Isn't it enough to cast $value to an integer and ensure it's not < 0?

You can enter "3.1415926" and casting to int is "3" which would pass the test but then we end up storing a float value. This is the best way to ensure the user is entering an *integer* number.

>If not, let's comment this because it's very weird.

Comment added.

+++ modules/simpletest/simpletest.install 4 Aug 2009 02:26:50 -0000
@@ -132,6 +133,7 @@
+  $can_set_time_limit = !ini_get('safe_mode') && strpos(ini_get('disable_functions'), 'set_time_limit') === FALSE;

>
>Is checking for function_exists('set_time_limit') not sufficient here?

The function could exist but we could be running in safe_mode, then calling that function has no effect. We need to warn people about that.

+++ modules/simpletest/simpletest.install 4 Aug 2009 02:26:50 -0000
@@ -156,7 +158,16 @@
+    $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');

>
>disabled. php.ini should be followed by a period since it ends the sentence.

I made the change. I hope I understand you correctly.

boombatower’s picture

Status: Needs review » Needs work
+++ modules/simpletest/simpletest.install	9 Aug 2009 07:26:03 -0000
@@ -156,7 +158,16 @@ function simpletest_requirements($phase)
+    'title' => $t('Can call %f', array('%f' => 'set_time_limit()')),

Single letter placeholders are not generally used, lets change to %function.

+++ modules/simpletest/simpletest.pages.inc	9 Aug 2009 07:26:03 -0000
@@ -453,3 +460,15 @@ function simpletest_settings_form(&$form
+  // ensure input value is an integer and not a float or non-integer

Comments begin with cap and end with period.

+++ modules/simpletest/simpletest.pages.inc	9 Aug 2009 07:26:03 -0000
@@ -453,3 +460,15 @@ function simpletest_settings_form(&$form
+  if ($value !== (string)(int)$value || $value < 0) {

I think "$value !== (string)(int)$value" could be changed to "$value != (int) $value". That would be a bit more standard as I don't think we need a strict compare here and it requires a double cast which, as webchick noted, is odd.

+++ modules/simpletest/simpletest.pages.inc	9 Aug 2009 07:26:03 -0000
@@ -453,3 +460,15 @@ function simpletest_settings_form(&$form
+    form_error($form['general']['simpletest_time_limit'], t('Must be an integer >= 0.'));

Form error messages should include the field name and should use plain english, '>=' should be 'greater then or equal to'.

Beer-o-mania starts in 18 days! Don't drink and patch.

boombatower’s picture

Status: Needs work » Needs review
StatusFileSize
new4.86 KB

I went ahead and made the changes and cleaned up the validate function.

The function never actually checked if the string was numeric, so 'a' was accepted.

(int) 'a'

Converts the character to its ord code. I added an is_numeric() check.

Status: Needs review » Needs work

The last submitted patch failed testing.

boombatower’s picture

Status: Needs work » Needs review
StatusFileSize
new4.71 KB

Confirmed it still works after re-roll. Since fatal errors pick it up...you get the following as the last assertion.

Maximum execution time of 1 second exceeded
mattyoung’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

dries’s picture

Status: Reviewed & tested by the community » Needs review

I don't understand why we want to make this is a settings versus just bumping the value. That sounds like a really marginal use case to me, and would justify many more things to be settings.

In the description, shouldn't 'error' be 'errors'?

webchick’s picture

Agreed. Shouldn't we just throw the set_time_limit() call before each testXX function? The docs http://ca.php.net/set_time_limit indicate that it re-starts the timer each time it is called. If the underlying bug is that the scripts are running out of time, that just means we have to call it more often to reset the timer sooner, no?

mattyoung’s picture

It's a good idea to call set_time_limit() to restart the timer on each test.

For this patch, having a user option of setting to something is good. I get time out on the default. So with this, I just set it to zero to have no time limit. You never know what kind a slow machine people might be running on.

boombatower’s picture

So settings...and per test method good with everyone?

dries’s picture

Why not hard-code the value to 500 or use a define?

And yes, set the value before each function.

boombatower’s picture

Not sure it will solve for all machines, but sure. Patch in a moment.

boombatower’s picture

StatusFileSize
new592 bytes

The reason for leaving as class property is that tests can override if they need more time.

dries’s picture

I think that does the job, unless proven otherwise.

Status: Needs review » Needs work

The last submitted patch failed testing.

boombatower’s picture

Status: Needs work » Needs review
boombatower’s picture

ping

boombatower’s picture

Status: Needs review » Reviewed & tested by the community

Seems appropriate.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.