Use TEST_TMPDIR on MacOS as well if available.

Currently MacOS falls back to generic /tmp, but
for all intents and purposes it should behave like
other Unixes using the TEST_TMPDIR environment variable
if available (this environment variable is set in bazel,
which sets up a unique temp directory for the test
process).

While at it, remove an incorrect #endif comment, that
looks like a leftover from some older implementation.

PiperOrigin-RevId: 446108391
Change-Id: I118eacf6e86a41d26cb81a130f7c54cccc0c5665
This commit is contained in:
Abseil Team 2022-05-02 21:55:51 -07:00 committed by Copybara-Service
parent 42ca3da579
commit 0027cf4703

View File

@ -6766,7 +6766,7 @@ std::string TempDir() {
} else {
return temp_dir;
}
#elif GTEST_OS_LINUX
#elif GTEST_OS_LINUX || GTEST_OS_MAC
const char* temp_dir = internal::posix::GetEnv("TEST_TMPDIR");
if (temp_dir == nullptr || temp_dir[0] == '\0') {
return "/tmp/";
@ -6775,7 +6775,7 @@ std::string TempDir() {
}
#else
return "/tmp/";
#endif // GTEST_OS_WINDOWS_MOBILE
#endif
}
// Class ScopedTrace