aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-12-01 11:57:57 -0500
committerRuss Cox <rsc@golang.org>2017-12-01 21:09:19 +0000
commit496688b3cf81f92ee55c359cfbd8cd2c9d71c813 (patch)
treee5c6fc61339e0ab23dc8eb5b4855b99856e816ab /src
parent7684fe0bf1b60495621f888483199867ed52d54a (diff)
downloadgo-496688b3cf81f92ee55c359cfbd8cd2c9d71c813.tar.xz
cmd/go: honor -timeout=0 to mean no timeout
The test binaries accept -timeout=0 to mean no timeout, but then the backup timer in cmd/go kills the test after 1 minute. Make cmd/go understand this special case and change behavior accordingly. Fixes #14780. Change-Id: I66bf517173a4ad21d53a5ee88d163f04b8929fb6 Reviewed-on: https://go-review.googlesource.com/81499 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/alldocs.go7
-rw-r--r--src/cmd/go/internal/test/test.go5
-rw-r--r--src/testing/testing.go2
3 files changed, 10 insertions, 4 deletions
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go
index 918e1a1e17..fd5b01c92a 100644
--- a/src/cmd/go/alldocs.go
+++ b/src/cmd/go/alldocs.go
@@ -1199,9 +1199,9 @@
// GO386
// For GOARCH=386, the floating point instruction set.
// Valid values are 387, sse2.
-// GOMIPS
-// For GOARCH=mips{,le}, whether to use floating point instructions.
-// Valid values are hardfloat (default), softfloat.
+// GOMIPS
+// For GOARCH=mips{,le}, whether to use floating point instructions.
+// Valid values are hardfloat (default), softfloat.
//
// Special-purpose environment variables:
//
@@ -1575,6 +1575,7 @@
//
// -timeout d
// If a test binary runs longer than duration d, panic.
+// If d is 0, the timeout is disabled.
// The default is 10 minutes (10m).
//
// -v
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go
index e06d7dbbca..408698e416 100644
--- a/src/cmd/go/internal/test/test.go
+++ b/src/cmd/go/internal/test/test.go
@@ -272,6 +272,7 @@ const testFlag2 = `
-timeout d
If a test binary runs longer than duration d, panic.
+ If d is 0, the timeout is disabled.
The default is 10 minutes (10m).
-v
@@ -549,6 +550,10 @@ func runTest(cmd *base.Command, args []string) {
// timer does not get a chance to fire.
if dt, err := time.ParseDuration(testTimeout); err == nil && dt > 0 {
testKillTimeout = dt + 1*time.Minute
+ } else if err == nil && dt == 0 {
+ // An explicit zero disables the test timeout.
+ // Let it have one century (almost) before we kill it.
+ testKillTimeout = 100 * 365 * 24 * time.Hour
}
// show passing test output (after buffering) with -v flag.
diff --git a/src/testing/testing.go b/src/testing/testing.go
index e12b622b03..cddd475fd7 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -265,7 +265,7 @@ var (
mutexProfile = flag.String("test.mutexprofile", "", "write a mutex contention profile to the named file after execution")
mutexProfileFraction = flag.Int("test.mutexprofilefraction", 1, "if >= 0, calls runtime.SetMutexProfileFraction()")
traceFile = flag.String("test.trace", "", "write an execution trace to `file`")
- timeout = flag.Duration("test.timeout", 0, "panic test binary after duration `d` (0 means unlimited)")
+ timeout = flag.Duration("test.timeout", 0, "panic test binary after duration `d` (default 0, timeout disabled)")
cpuListStr = flag.String("test.cpu", "", "comma-separated `list` of cpu counts to run each test with")
parallel = flag.Int("test.parallel", runtime.GOMAXPROCS(0), "run at most `n` tests in parallel")