This is a test helper specifically for working around races when changing directories in test cases. As a public API it is very weird and deadlock-prone.
Not sure the best place for it. Perhaps std::unstable, though there's also a std::rt::test module for runtime test helpers.