]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: avoid leaking timer if test process failed to start
authorDave Cheney <dave@cheney.net>
Sat, 5 Jan 2013 10:15:51 +0000 (21:15 +1100)
committerDave Cheney <dave@cheney.net>
Sat, 5 Jan 2013 10:15:51 +0000 (21:15 +1100)
R=rsc
CC=golang-dev
https://golang.org/cl/7034047

src/cmd/go/test.go

index 87ae571bd3c227ba86441c9ba65bce1aff0eda39..5d3f21e5e9a89c5c80033e7d44101c508f23f35e 100644 (file)
@@ -642,8 +642,8 @@ func (b *builder) runTest(a *action) error {
        // This is a last-ditch deadline to detect and
        // stop wedged test binaries, to keep the builders
        // running.
-       tick := time.NewTimer(testKillTimeout)
        if err == nil {
+               tick := time.NewTimer(testKillTimeout)
                startSigHandlers()
                done := make(chan error)
                go func() {
@@ -660,8 +660,7 @@ func (b *builder) runTest(a *action) error {
                tick.Stop()
        }
        out := buf.Bytes()
-       t1 := time.Now()
-       t := fmt.Sprintf("%.3fs", t1.Sub(t0).Seconds())
+       t := fmt.Sprintf("%.3fs", time.Since(t0).Seconds())
        if err == nil {
                if testShowPass {
                        a.testOutput.Write(out)