@@ -28,28 +28,28 @@ func TimeOut(t time.Duration) *time.Timer {
2828 })
2929}
3030
31- // CheckRoutines is used to check for leaked go-routines
32- func CheckRoutines (t * testing.T ) func () {
33- tryLoop := func (failMessage string ) {
34- try := 0
35- ticker := time .NewTicker (200 * time .Millisecond )
36- defer ticker .Stop ()
37- for range ticker .C {
38- runtime .GC ()
39- routines := getRoutines ()
40- if len (routines ) == 0 {
41- return
42- }
43- if try >= 50 {
44- t .Fatalf ("%s: \n %s" , failMessage , strings .Join (routines , "\n \n " )) // nolint
45- }
46- try ++
31+ func tryCheckRoutinesLoop (tb testing.TB , failMessage string ) {
32+ try := 0
33+ ticker := time .NewTicker (200 * time .Millisecond )
34+ defer ticker .Stop ()
35+ for range ticker .C {
36+ runtime .GC ()
37+ routines := getRoutines ()
38+ if len (routines ) == 0 {
39+ return
4740 }
41+ if try >= 50 {
42+ tb .Fatalf ("%s: \n %s" , failMessage , strings .Join (routines , "\n \n " )) // nolint
43+ }
44+ try ++
4845 }
46+ }
4947
50- tryLoop ("Unexpected routines on test startup" )
48+ // CheckRoutines is used to check for leaked go-routines
49+ func CheckRoutines (t * testing.T ) func () {
50+ tryCheckRoutinesLoop (t , "Unexpected routines on test startup" )
5151 return func () {
52- tryLoop ( "Unexpected routines on test end" )
52+ tryCheckRoutinesLoop ( t , "Unexpected routines on test end" )
5353 }
5454}
5555
@@ -58,6 +58,7 @@ func CheckRoutines(t *testing.T) func() {
5858// for lingering goroutines. This is helpful for tests that need
5959// to ensure clean closure of resources.
6060func CheckRoutinesStrict (tb testing.TB ) func () {
61+ tryCheckRoutinesLoop (tb , "Unexpected routines on test startup" )
6162 return func () {
6263 routines := getRoutines ()
6364 if len (routines ) == 0 {
0 commit comments