I'd like to create a temporary file for a unit test. It looks like I can use a combination of CreateAndOpenTemporaryFile, ScopedFILEClose, and Delete to create and clean up the file.
My concern is that if the test becomes flaky or early exits, then the system temp directory will get clogged with temporary files. Are there other tests which work around this?
[As background, I'm trying to make RedirectTest.ClientEmptyReferer work with a non-fixed-port TestServer. The test wants to validate that a redirect from a file:// URL does not add a Referer header. I can't think of a way to avoid the need for a file in this case.]