cmd/go: add per-test timeouts
Tests have an overall timeout for the entire binary but no timeout for a specific test case. You often want to limit any particular test case to a time much shorter than the overall binary. I propose to add the concept of per-test (function) timeouts to the go command user experience as follows. 1. Each test gets a per-test timeout. The timer for a given test only ticks down when the test is running. It does not tick down when the test is blocked in t.Parallel, nor when it is blocked in t.Run running a subtest. 2. The default per-test case timeout is 1m (one minute). If the new `-testtimeout` flag is specified explicitly, then that sets a different default. If the `-testtimeout` flag is omitted but `-timeout` is specified explicitly, then that sets the default too. This way, if you have one really long test and use `go test -timeout=30m`, the per-case timeout doesn't kick in after 1 minute and kill it anyway. 3. There is a new testing.TB method `SetTimeout(d time.Duration)` that allows a test to set its own timeout. Calling SetTimeout does not reset the timer. If a test runs for 30 seconds and then calls `t.SetTimeout(1*time.Second)`, it gets killed for having timed out. A timeout set this way is inherited by subtests. (They each have their own timer.) 4. When a test timeout happens, the whole process still gets killed. There's nothing we can really do about that. But the failure does say which test function timed out. This change will help users generally, and it will a
Posted by rsc on Sep 2, 2021, 5:10 PM
Tags
Related issues
- The issue is really the extreme difficulty of programming them, especially for anything sequential (rather than combinatorial).
- I probably could have beared with it if it was only limited to programming, but it showing up in creative fields has made me feel all sor...
- I hate that I'm in deep enough to know what you mean.
- The biggest problem with “AI” is that big corps are shoving it down our throats.
- in the middel of a coding session with 5.6 sol.
- [Hero Run] 535B-A23B on 18T tokens
Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments
reliability (Other)
The issue is really the extreme difficulty of programming them, especially for anything sequential (rather than combinatorial).
I probably could have beared with it if it was only limited to programming, but it showing up in creative fields has made me feel all sor...
I hate that I'm in deep enough to know what you mean.
The biggest problem with “AI” is that big corps are shoving it down our throats.
in the middel of a coding session with 5.6 sol.
[Hero Run] 535B-A23B on 18T tokens
I hate that this is how AI is being used..
inexperienced protobuf user here -- why do non-googlers generally use protobuf?
cmd/go: add per-test timeouts
Tests have an overall timeout for the entire binary but no timeout for a specific test case. You often want to limit any particular test case to a time much shorter than the overall binary. I propose to add the concept of per-test (function) timeouts to the go command user experience as follows. 1. Each test gets a per-test timeout. The timer for a given test only ticks down when the test is running. It does not tick down when the test is blocked in t.Parallel, nor when it is blocked in t.Run running a subtest. 2. The default per-test case timeout is 1m (one minute). If the new `-testtimeout` flag is specified explicitly, then that sets a different default. If the `-testtimeout` flag is omitted but `-timeout` is specified explicitly, then that sets the default too. This way, if you have one really long test and use `go test -timeout=30m`, the per-case timeout doesn't kick in after 1 minute and kill it anyway. 3. There is a new testing.TB method `SetTimeout(d time.Duration)` that allows a test to set its own timeout. Calling SetTimeout does not reset the timer. If a test runs for 30 seconds and then calls `t.SetTimeout(1*time.Second)`, it gets killed for having timed out. A timeout set this way is inherited by subtests. (They each have their own timer.) 4. When a test timeout happens, the whole process still gets killed. There's nothing we can really do about that. But the failure does say which test function timed out. This change will help users generally, and it will a
Comments (0)
No comments yet. Start the discussion.