-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
Could we add a shutdown/cleanup mechanism to the testing package? Background: some tests (notably: integration-style tests) require heavy setup, compiling things, setting up things on disk, running child processes wired together, etc. If you just do this once and share it per test, it's unclear when to clean up the /tmp folder and shut down the processes. People have resorted to things like TestZZZ for cleanup (which doesn't work well with -test.run), or z_last_test.go (as seen in net/http), or the hoops jumped through here: https://github.com/bradfitz/docker/blob/fuse/vfuse/all_test.go (Look at release and testsToRun and how it's calculated.) And also hacks in Google's code, even people so far as to fork the testing package. Or people run a child process that is responsible for cleanup, once it notices its parent has died. But that's a lot of work and there are portability concerns. I know a test could still crash mid-way through, so cleanup on shutdown is still best effort, but when it's a bunch of big processes and big files in /tmp, that's better than nothing most the time. With regard to atexit-ish concerns, I'd propose the shutdown mechanism itself be subject to the same timeout concerns. If the shutdown doesn't finish in N seconds, the test exits with failure.
Reactions are currently unavailable