diff options
author | OkamotoYuki <okamoto.yuki.0130@gmail.com> | 2019-03-10 02:38:12 +0000 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2019-04-13 02:39:29 +0000 |
commit | ee64b35531a841ab4dbe41c17390214f9dea654f (patch) | |
tree | f26098e80dd90904024a16b961f3911824d65412 /src/cmd/go/internal/test/test.go | |
parent | c40bffd90535bd9d5bf6a398f5227ff2c9aaed52 (diff) | |
download | go-ee64b35531a841ab4dbe41c17390214f9dea654f.tar.gz go-ee64b35531a841ab4dbe41c17390214f9dea654f.zip |
cmd/go/internal/test: pass default timeout to test programs if not given from command line
Make 'go test' command to pass the default timeout (10m) to test programs if the value is not given from command line.
Fixes #28147
Change-Id: I7856e452224a51a92da03bab8e3a0f9d7c41d32a
GitHub-Last-Rev: 66f9a6f90e9ffe7c58d5c1fe32af84e16ea74ab8
GitHub-Pull-Request: golang/go#30545
Reviewed-on: https://go-review.googlesource.com/c/go/+/164963
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/test/test.go')
-rw-r--r-- | src/cmd/go/internal/test/test.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index 225dab31de..9b9bbce0dd 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -484,8 +484,9 @@ var ( pkgArgs []string pkgs []*load.Package - testKillTimeout = 10 * time.Minute - testCacheExpire time.Time // ignore cached test results before this time + testActualTimeout = 10 * time.Minute // actual timeout which is passed to tests + testKillTimeout = testActualTimeout + 1*time.Minute // backup alarm + testCacheExpire time.Time // ignore cached test results before this time ) // testVetFlags is the list of flags to pass to vet when invoked automatically during go test. @@ -552,13 +553,21 @@ func runTest(cmd *base.Command, args []string) { // the test wedges with a goroutine spinning and its background // timer does not get a chance to fire. if dt, err := time.ParseDuration(testTimeout); err == nil && dt > 0 { - testKillTimeout = dt + 1*time.Minute + testActualTimeout = dt + testKillTimeout = testActualTimeout + 1*time.Minute } else if err == nil && dt == 0 { // An explicit zero disables the test timeout. + // No timeout is passed to tests. // Let it have one century (almost) before we kill it. + testActualTimeout = -1 testKillTimeout = 100 * 365 * 24 * time.Hour } + // Pass timeout to tests if it exists. + if testActualTimeout > 0 { + testArgs = append(testArgs, "-test.timeout="+testActualTimeout.String()) + } + // show passing test output (after buffering) with -v flag. // must buffer because tests are running in parallel, and // otherwise the output will get mixed. |