mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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:
parent
21315c3428
commit
bd0a14fe40
1 changed files with 4 additions and 7 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue