Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
testing: go test shouldn't terminate if leftover process remain when executed in verbose mode (-v flag) #12538
go version go1.5 linux/amd64
I wrote a test that didn' terminate in normal mode, but did terminate when running in verbose mode (
The test uses a TestMain function that looked like:
The problem being that
This is obviously a problem with the test, but I still believe that the
I don't see how -test.v could affect this. Also package testing did not call os.Exit: your code did. If you don't want your program to exit, don't call os.Exit. If it does call os.Exit, there's nothing package testing can do about that.
In general it is fine to have background goroutines running at exit. And while we might look for child subprocesses, some child subprocesses might be okay (for example if the test invoked something that kicked off a background daemon as part of its operation). Inserting that kind of check into package testing seems unwise.