Closed cornelk closed 2 years ago
This issue has been closed even though the fix isn't tagged for any release.
And just FYI, this fix cannot work with VerifyTestMain since you cannot trigger a cleanup before checking for leaks. You must basically reimplement it:
func TestMain(m *testing.M) {
exitcode := 0
defer func() { os.Exit(exitcode) }
exitcode = m.Run()
view.Stop()
if err := goleak.Find(); err != nil {
fmt.Fprintf(os.Stderr, "goleak: Errors on successful test run: %v\n", err)
exitcode = 1
}
}
IMO a package init()
shouldn't be starting threads.
Currently there is no way to stop the
defaultWorker
goroutine in thego.opencensus.io/stats/view/
package. This breaks adding a Goroutine leak detector to unit tests in packages that import the view package as it will always fail: