if err != nil {
t.err = fmt.Errorf("need number of seconds for -t timeout, got %s instead", args[0])
}
+ if s := os.Getenv("GO_TEST_TIMEOUT_SCALE"); s != "" {
+ timeoutScale, err := strconv.Atoi(s)
+ if err != nil {
+ log.Fatalf("failed to parse $GO_TEST_TIMEOUT_SCALE = %q as integer: %v", s, err)
+ }
+ tim *= timeoutScale
+ }
case "-goexperiment": // set GOEXPERIMENT environment
args = args[1:]
if goexp != "" {
if tim != 0 {
err = cmd.Start()
// This command-timeout code adapted from cmd/go/test.go
+ // Note: the Go command uses a more sophisticated timeout
+ // strategy, first sending SIGQUIT (if appropriate for the
+ // OS in question) to try to trigger a stack trace, then
+ // finally much later SIGKILL. If timeouts prove to be a
+ // common problem here, it would be worth porting over
+ // that code as well. See https://do.dev/issue/50973
+ // for more discussion.
if err == nil {
tick := time.NewTimer(time.Duration(tim) * time.Second)
done := make(chan error)