diff options
| author | Alberto Donizetti <alb.donizetti@gmail.com> | 2017-01-29 20:53:35 +0100 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2017-01-31 17:36:49 +0000 |
| commit | 7d8bfdde453445affb50fcaeacc050938ec98467 (patch) | |
| tree | 138f35ab40ed0b453d4982d89f0d8b69b45316d9 | |
| parent | 3e55059f305bde37a4dac1397e8a1b798b6fbd9e (diff) | |
| download | go-7d8bfdde453445affb50fcaeacc050938ec98467.tar.xz | |
testing: stop timeout-timer after running tests
Fixes #18845
Change-Id: Icdc3e2067807781e42f2ffc94d1824aed94d3713
Reviewed-on: https://go-review.googlesource.com/35956
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
| -rw-r--r-- | src/cmd/go/go_test.go | 7 | ||||
| -rw-r--r-- | src/cmd/go/testdata/timeoutbench_test.go | 10 | ||||
| -rw-r--r-- | src/testing/testing.go | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index f26c3660e4..ef5348bba4 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -3744,6 +3744,13 @@ func TestMatchesOnlySubtestParallelIsOK(t *testing.T) { tg.grepBoth(okPattern, "go test did not say ok") } +// Issue 18845 +func TestBenchTimeout(t *testing.T) { + tg := testgo(t) + defer tg.cleanup() + tg.run("test", "-bench", ".", "-timeout", "750ms", "testdata/timeoutbench_test.go") +} + func TestLinkXImportPathEscape(t *testing.T) { // golang.org/issue/16710 tg := testgo(t) diff --git a/src/cmd/go/testdata/timeoutbench_test.go b/src/cmd/go/testdata/timeoutbench_test.go new file mode 100644 index 0000000000..57a8888299 --- /dev/null +++ b/src/cmd/go/testdata/timeoutbench_test.go @@ -0,0 +1,10 @@ +package timeoutbench_test + +import ( + "testing" + "time" +) + +func BenchmarkSleep1s(b *testing.B) { + time.Sleep(1 * time.Second) +} diff --git a/src/testing/testing.go b/src/testing/testing.go index ddbdc25bf1..bd19a31c27 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -821,6 +821,7 @@ func (m *M) Run() int { haveExamples = len(m.examples) > 0 testRan, testOk := runTests(m.deps.MatchString, m.tests) exampleRan, exampleOk := runExamples(m.deps.MatchString, m.examples) + stopAlarm() if !testRan && !exampleRan && *matchBenchmarks == "" { fmt.Fprintln(os.Stderr, "testing: warning: no tests to run") } |
