aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-02-11 18:00:58 -0500
committerRuss Cox <rsc@golang.org>2011-02-11 18:00:58 -0500
commita93c994bcf4c3ca75a25f2703ab7a66d9a84c4e3 (patch)
treecea415dd3ad139c32cb9d06836f4cedb550ed911
parentb57ac97c27e8c5b8b9ff0e11c6dec538faa3eb43 (diff)
downloadgo-a93c994bcf4c3ca75a25f2703ab7a66d9a84c4e3.tar.gz
go-a93c994bcf4c3ca75a25f2703ab7a66d9a84c4e3.zip
testing: include elapsed time in output
R=r CC=golang-dev https://golang.org/cl/4180045
-rw-r--r--src/pkg/testing/testing.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pkg/testing/testing.go b/src/pkg/testing/testing.go
index 0e04935ce4..edbf0847cc 100644
--- a/src/pkg/testing/testing.go
+++ b/src/pkg/testing/testing.go
@@ -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)
}
}