Commit 0e202cdb by Abseil Team Committed by Mark Barolak

Googletest export

Use environment variable TEST_TMPDIR in Linux environments for temporary directory if available otherwise use /tmp/. Bazel sets the environment variable TEST_TMPDIR when launching tests. PiperOrigin-RevId: 342058921
parent a1adec79
...@@ -6557,18 +6557,27 @@ std::string TempDir() { ...@@ -6557,18 +6557,27 @@ std::string TempDir() {
return "\\temp\\"; return "\\temp\\";
#elif GTEST_OS_WINDOWS #elif GTEST_OS_WINDOWS
const char* temp_dir = internal::posix::GetEnv("TEMP"); const char* temp_dir = internal::posix::GetEnv("TEMP");
if (temp_dir == nullptr || temp_dir[0] == '\0') if (temp_dir == nullptr || temp_dir[0] == '\0') {
return "\\temp\\"; return "\\temp\\";
else if (temp_dir[strlen(temp_dir) - 1] == '\\') } else if (temp_dir[strlen(temp_dir) - 1] == '\\') {
return temp_dir; return temp_dir;
else } else {
return std::string(temp_dir) + "\\"; return std::string(temp_dir) + "\\";
}
#elif GTEST_OS_LINUX_ANDROID #elif GTEST_OS_LINUX_ANDROID
const char* temp_dir = internal::posix::GetEnv("TEST_TMPDIR"); const char* temp_dir = internal::posix::GetEnv("TEST_TMPDIR");
if (temp_dir == nullptr || temp_dir[0] == '\0') if (temp_dir == nullptr || temp_dir[0] == '\0') {
return "/data/local/tmp/"; return "/data/local/tmp/";
else } else {
return temp_dir;
}
#elif GTEST_OS_LINUX
const char* temp_dir = internal::posix::GetEnv("TEST_TMPDIR");
if (temp_dir == nullptr || temp_dir[0] == '\0') {
return "/tmp/";
} else {
return temp_dir; return temp_dir;
}
#else #else
return "/tmp/"; return "/tmp/";
#endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS_MOBILE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment