]> Cypherpunks repositories - gostls13.git/commitdiff
testing: include elapsed time in output
authorRuss Cox <rsc@golang.org>
Fri, 11 Feb 2011 23:00:58 +0000 (18:00 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 11 Feb 2011 23:00:58 +0000 (18:00 -0500)
R=r
CC=golang-dev
https://golang.org/cl/4180045

src/pkg/testing/testing.go

index 0e04935ce449ddc70c5bce2f151a04501436e3a0..edbf0847cc05b16c23a2c5c77968daea3f506307 100644 (file)
@@ -43,6 +43,7 @@ import (
        "fmt"
        "os"
        "runtime"
+       "time"
 )
 
 // Report as tests are run; default is silent for success.
@@ -153,16 +154,19 @@ func Main(matchString func(pat, str string) (bool, os.Error), tests []InternalTe
                if *chatty {
                        println("=== RUN ", tests[i].Name)
                }
+               ns := -time.Nanoseconds()
                t := new(T)
                t.ch = make(chan *T)
                go tRunner(t, &tests[i])
                <-t.ch
+               ns += time.Nanoseconds()
+               tstr := fmt.Sprintf("(%.1f seconds)", float64(ns)/1e9)
                if t.failed {
-                       println("--- FAIL:", tests[i].Name)
+                       println("--- FAIL:", tests[i].Name, tstr)
                        print(t.errors)
                        ok = false
                } else if *chatty {
-                       println("--- PASS:", tests[i].Name)
+                       println("--- PASS:", tests[i].Name, tstr)
                        print(t.errors)
                }
        }