Commit bd0a14fe authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

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
parent 21315c34
......@@ -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))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment