Test '-timeout 0' not reflected in execution
Test '-timeout 0' not reflected in execution
I am using Go 1.9.2 version and invoking the test with timeout disabled using -timeout 0
flag.
-timeout 0
go test my_module -run TestModule -v --race -timeout 0
go test my_module -run TestModule -v --race -timeout 0
But the test execution is getting timed out after default timeout of 10m.
*** Test killed: ran too long (10m0s).
2 Answers
2
It's test.timeout
i.e.
test.timeout
go test my_module -run TestModule -v --race -test.timeout 0
go test my_module -run TestModule -v --race -test.timeout 0
Its the way the testing
library is handling that flag value:
testing
https://github.com/golang/go/blob/adcecbe05ef812bc8ff477dec47720a2cfc273e3/src/testing/testing.go#L1299
It only uses the given value if the timeout
is greater than 0
. Therefore, by setting it to 0, it just uses the default (10m
).
timeout
0
10m
Zero (0)
https://github.com/golang/go/blob/adcecbe05ef812bc8ff477dec47720a2cfc273e3/src/testing/testing.go#L271
Right, if you had done
-timeout 1
, it would be set to 1
instead and be a very quick timeout.– poy
Sep 17 '18 at 15:14
-timeout 1
1
So it doesn't solve the problem I have mentioned. How to get that working in this version ?
– Ashwin
Sep 18 '18 at 5:17
I'm not sure I understand your problem. Why do you want to have the test immediately timeout?
– poy
Oct 2 '18 at 2:01
All I want is to disable timeout for my go test. But currently if I use
-timeout 0
, the test still timesout after the default time of 10m
– Ashwin
Oct 4 '18 at 7:55
-timeout 0
10m
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
But the code is anyway going to set it to
Zero (0)
as per the linehttps://github.com/golang/go/blob/adcecbe05ef812bc8ff477dec47720a2cfc273e3/src/testing/testing.go#L271
. So passing the same value as part of external params will be behaving the same I guess– Ashwin
Sep 17 '18 at 6:25