mirror of
https://github.com/golang/go
synced 2024-11-22 01:04:40 -07:00
testing: include elapsed time in output
R=r CC=golang-dev https://golang.org/cl/4180045
This commit is contained in:
parent
b57ac97c27
commit
a93c994bcf
@ -43,6 +43,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Report as tests are run; default is silent for success.
|
// 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 {
|
if *chatty {
|
||||||
println("=== RUN ", tests[i].Name)
|
println("=== RUN ", tests[i].Name)
|
||||||
}
|
}
|
||||||
|
ns := -time.Nanoseconds()
|
||||||
t := new(T)
|
t := new(T)
|
||||||
t.ch = make(chan *T)
|
t.ch = make(chan *T)
|
||||||
go tRunner(t, &tests[i])
|
go tRunner(t, &tests[i])
|
||||||
<-t.ch
|
<-t.ch
|
||||||
|
ns += time.Nanoseconds()
|
||||||
|
tstr := fmt.Sprintf("(%.1f seconds)", float64(ns)/1e9)
|
||||||
if t.failed {
|
if t.failed {
|
||||||
println("--- FAIL:", tests[i].Name)
|
println("--- FAIL:", tests[i].Name, tstr)
|
||||||
print(t.errors)
|
print(t.errors)
|
||||||
ok = false
|
ok = false
|
||||||
} else if *chatty {
|
} else if *chatty {
|
||||||
println("--- PASS:", tests[i].Name)
|
println("--- PASS:", tests[i].Name, tstr)
|
||||||
print(t.errors)
|
print(t.errors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user