mirror of
https://github.com/golang/go
synced 2024-10-04 15:09:59 +00:00
test: make goprint.go wait for goroutine termination
Test goprint.go sometimes failed on a slow builder (plan9_arm) because of timing dependency. Instead of sleeping for a fixed time to allow the child goroutine to finish, wait explicitly for child termination by calling runtime.NumGoroutine until the returned value is 1. Fixes #15097 Change-Id: Ib3ef5ec3c8277083c774542f48bcd4ff2f79efde Reviewed-on: https://go-review.googlesource.com/21603 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
5176a4b39b
commit
a25e368f44
|
@ -8,9 +8,14 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"runtime"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
go println(42, true, false, true, 1.5, "world", (chan int)(nil), []int(nil), (map[string]int)(nil), (func())(nil), byte(255))
|
go println(42, true, false, true, 1.5, "world", (chan int)(nil), []int(nil), (map[string]int)(nil), (func())(nil), byte(255))
|
||||||
time.Sleep(100*time.Millisecond)
|
for runtime.NumGoroutine() > 1 {
|
||||||
|
time.Sleep(10*time.Millisecond)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue