]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: apply timeout scale even if timeout isn't overridden
authorDmitri Shuralyov <dmitshur@golang.org>
Thu, 20 Jul 2023 14:23:47 +0000 (10:23 -0400)
committerGopher Robot <gobot@golang.org>
Fri, 21 Jul 2023 14:41:57 +0000 (14:41 +0000)
The timeout field is documented as being available so that it's possible
to override timeout by setting a non-zero value. If it's left at zero,
we don't need to override the default go test timeout, but we still need
to apply the timeout scale whenever it's something other than 1.

Fixes (via backport) #61468.

Change-Id: I63634e9b3ef8c4ec7f334b5a6b4bf3cad121355c
Reviewed-on: https://go-review.googlesource.com/c/go/+/511567
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

src/cmd/dist/test.go
src/cmd/go/internal/test/testflag.go

index bd02149c115e8379ba4cddb4b2906f930ed3ff8e..554adea1b17ba51ba7bdab61ee482cf733402b3c 100644 (file)
@@ -405,6 +405,9 @@ func (opts *goTest) buildArgs(t *tester) (build, run, pkgs, testFlags []string,
        if opts.timeout != 0 {
                d := opts.timeout * time.Duration(t.timeoutScale)
                run = append(run, "-timeout="+d.String())
+       } else if t.timeoutScale != 1 {
+               const goTestDefaultTimeout = 10 * time.Minute // Default value of go test -timeout flag.
+               run = append(run, "-timeout="+(goTestDefaultTimeout*time.Duration(t.timeoutScale)).String())
        }
        if opts.short || t.short {
                run = append(run, "-short")
index 970c2f59e9aa16a61426e80a9b8c48c549800f38..425378889d9af06da941763ab25c90ca4f81142c 100644 (file)
@@ -61,7 +61,7 @@ func init() {
        cf.String("run", "", "")
        cf.Bool("short", false, "")
        cf.String("skip", "", "")
-       cf.DurationVar(&testTimeout, "timeout", 10*time.Minute, "")
+       cf.DurationVar(&testTimeout, "timeout", 10*time.Minute, "") // known to cmd/dist
        cf.String("fuzztime", "", "")
        cf.String("fuzzminimizetime", "", "")
        cf.StringVar(&testTrace, "trace", "", "")