Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
19 Jul 2009 at 01:56 UTC
Updated:
27 Oct 2009 at 07:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
boombatower commentedSince we have had issues with tests timeing out they set the timeout themseleves
The default is:
and in DrupalWebTestCase::setUp()
Seems like your machine is taking longer than usual, could be CPU speed or something related to configuration.
Comment #2
mattyoung commentedOn 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.
Comment #3
boombatower commentedSeems 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.
Comment #4
mattyoung commented>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:
Comment #5
boombatower commentedRight, this just needs a patch.
Comment #6
mattyoung commentedHere 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().
Comment #7
boombatower commentedRe-rolled per: http://drupal.org/patch and cleaned up documentation.
Comment #8
mattyoung commentedadd form validation for simpletest_time_limit in case some one enter something crazy
Comment #10
mattyoung commentedRe-roll patch
Comment #11
boombatower commentedPatch looks a bit wacky since there is double line spacing. I haven't look at it in detail.
Comment #12
mattyoung commentedI 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.
Comment #13
mattyoung commentedRe-roll pactch. I made sure the files use unix eol style. I check the patch and it look okay to me.
Comment #14
boombatower commentedShould be end of line...needs documentation...and remove extra blank line from above.
Otherwise looks fine.
Comment #15
mattyoung commentedRe-roll patch per instruction in previous message
Comment #16
mattyoung commentedforgot to change status.
Comment #17
boombatower commentedto
I tested this with a value of 1 and it timedout....so looks good.
Comment #18
webchickShorten so fits into one line, or add one-line summary.
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.
Is checking for function_exists('set_time_limit') not sufficient here?
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.
Comment #19
mattyoung commented>
>Shorten so fits into one line, or add one-line summary.
Okay.
>
>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.
>
>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.
>
>disabled. php.ini should be followed by a period since it ends the sentence.
I made the change. I hope I understand you correctly.
Comment #20
boombatower commentedSingle letter placeholders are not generally used, lets change to %function.
Comments begin with cap and end with period.
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.
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.
Comment #21
boombatower commentedI 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.
Converts the character to its ord code. I added an is_numeric() check.
Comment #23
boombatower commentedConfirmed it still works after re-roll. Since fatal errors pick it up...you get the following as the last assertion.
Comment #24
mattyoung commentedLooks good.
Comment #25
dries commentedI 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'?
Comment #26
webchickAgreed. 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?
Comment #27
mattyoung commentedIt'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.
Comment #28
boombatower commentedSo settings...and per test method good with everyone?
Comment #29
dries commentedWhy not hard-code the value to 500 or use a define?
And yes, set the value before each function.
Comment #30
boombatower commentedNot sure it will solve for all machines, but sure. Patch in a moment.
Comment #31
boombatower commentedThe reason for leaving as class property is that tests can override if they need more time.
Comment #32
dries commentedI think that does the job, unless proven otherwise.
Comment #34
boombatower commentedComment #35
boombatower commentedping
Comment #36
boombatower commentedSeems appropriate.
Comment #37
webchickCommitted to HEAD!