Go runs fn in a goroutine and waits until fn has completed before test completion. Done is returned for optionally waiting for fn to exit.
(t *testing.T, fn func())
| 8 | // test completion. Done is returned for optionally waiting for fn to |
| 9 | // exit. |
| 10 | func Go(t *testing.T, fn func()) (done <-chan struct{}) { |
| 11 | t.Helper() |
| 12 | |
| 13 | doneC := make(chan struct{}) |
| 14 | t.Cleanup(func() { |
| 15 | <-doneC |
| 16 | }) |
| 17 | go func() { |
| 18 | fn() |
| 19 | close(doneC) |
| 20 | }() |
| 21 | |
| 22 | return doneC |
| 23 | } |