]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: honor -timeout=0 to mean no timeout
authorRuss Cox <rsc@golang.org>
Fri, 1 Dec 2017 16:57:57 +0000 (11:57 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 1 Dec 2017 21:09:19 +0000 (21:09 +0000)
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>
src/cmd/go/alldocs.go
src/cmd/go/internal/test/test.go
src/testing/testing.go

index 918e1a1e1757bcc57013b60177ccda9dc4bd8f51..fd5b01c92a1a37d43126c256b4614bfe12e35983 100644 (file)
 //     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:
 //
 //
 //     -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
index e06d7dbbcacf0102069c2857f2cfe65fde1b40ff..408698e416210a57c5aefa90cc565f70697b0596 100644 (file)
@@ -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.
index e12b622b03d78c38d9066b7fca1bc28f74cbacb1..cddd475fd775fffb9990cfa849ff3fb18284dcfa 100644 (file)
@@ -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")