-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
The new T.TempDir method is documented to return the same path on every call within the same test:
Subsequent calls to t.TempDir return the same directory.
This means that it's easy for tests that use TempDir to shoot themselves in the foot by overwriting or reading content owned by testing libraries. To use TempDir correctly in the presence of multiple packages you must use a unique subdirectory name, which is hard to choose, so you'd need to use ioutil.TempDir which loses the whole point of having TempDir in the first place.
I propose that every call to TempDir return a new temporary directory; tests can save the result in a local variable if need be.
If it seems like the implied semantics of the name TempDir no longer match the actual behaviour, another possible name would be Mkdir.