]> Cypherpunks repositories - gostls13.git/commitdiff
test: apply GO_TEST_TIMEOUT_SCALE scaling to test timeouts
authorThan McIntosh <thanm@google.com>
Wed, 2 Feb 2022 19:09:26 +0000 (14:09 -0500)
committerThan McIntosh <thanm@google.com>
Mon, 7 Feb 2022 12:32:51 +0000 (12:32 +0000)
Change run.go to apply the GO_TEST_TIMEOUT_SCALE scaling factor to
test timeouts (mentioned in "-t" clause in test header).

Also with this patch, bump up the timeout for fixedbugs/issue46234.go
from 30 to 45 seconds, to avoid flakes on very slow builders.

Updates #50973.

Change-Id: Icbafa482860e24cc1e72fee53511bcc764d06bf1
Reviewed-on: https://go-review.googlesource.com/c/go/+/382774
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

test/fixedbugs/issue46234.go
test/run.go

index 8e7eb8bf8d2d668d4a103555926616d2886865ef..ed1c05cfbf4b811874ecc780b4099fa69b00dee0 100644 (file)
@@ -1,5 +1,6 @@
-// buildrun -t 30
+// buildrun -t 45
 
+//go:build !js
 // +build !js
 
 // Copyright 2021 The Go Authors. All rights reserved.
index 9ba421510ced9285e2029da8a00642c45dd13955..ae5afc751df087c96c9de31b11c12d8e52fac2fa 100644 (file)
@@ -710,6 +710,13 @@ func (t *test) run() {
                        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 != "" {
@@ -834,6 +841,13 @@ func (t *test) run() {
                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)