gotestyourself / gotestsum

'go test' runner with output optimized for humans, JUnit XML for CI integration, and a summary of the test results.
Apache License 2.0
2.03k stars 119 forks source link

feature request: global timeout #344

Open nfi-hashicorp opened 1 year ago

nfi-hashicorp commented 1 year ago

You can use the go test -timeout flag, but AFAICT, that wouldn't take into account retries.

dnephin commented 1 year ago

Hello! That's correct, the -test.timeout flag would only limit the time of each re-run. A --timeout flag seems like a reasonable addition, but I would like to avoid flags that mirror existing go test flags. Maybe --rerun-timeout to make it clear that it's only relevant to reruns.

Another option might be to examine the args passed to go test, and if we notice a -test.timeout or -timeout flag, use that timeout automatically. That won't work with --raw-command if the timeout is in the command and not the command line.

As a workaround the timeout command on linux should also work pretty well:

timeout -s INT 100 gotestsum ...

This signal handler will forward the interrupt to go test. With this approach we don't get the stack trace.

Another improvement would be to send SIGABRT to go test, which should give us a goroutine stack trace (like -test.timeout would) instead of only interrupting the run. I opened #346 to add support for sending SIGABRT.