1
0
mirror of https://github.com/golang/go synced 2024-11-22 01:44:40 -07:00

testing: say what was the timeout if it fires

It looks reasonable here and may be useful.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12252043
This commit is contained in:
Dmitriy Vyukov 2013-08-01 17:24:24 +04:00
parent 21315c3428
commit bd0a14fe40

View File

@ -371,12 +371,12 @@ func Main(matchString func(pat, str string) (bool, error), tests []InternalTest,
haveExamples = len(examples) > 0
testOk := RunTests(matchString, tests)
exampleOk := RunExamples(matchString, examples)
stopAlarm()
if !testOk || !exampleOk {
fmt.Println("FAIL")
os.Exit(1)
}
fmt.Println("PASS")
stopAlarm()
RunBenchmarks(matchString, benchmarks)
after()
}
@ -561,7 +561,9 @@ var timer *time.Timer
// startAlarm starts an alarm if requested.
func startAlarm() {
if *timeout > 0 {
timer = time.AfterFunc(*timeout, alarm)
timer = time.AfterFunc(*timeout, func() {
panic(fmt.Sprintf("test timed out after %v", *timeout))
})
}
}
@ -572,11 +574,6 @@ func stopAlarm() {
}
}
// alarm is called if the timeout expires.
func alarm() {
panic("test timed out")
}
func parseCpuList() {
if len(*cpuListStr) == 0 {
cpuList = append(cpuList, runtime.GOMAXPROCS(-1))