From 7a60b1abe8be0a2790f7c7aebd2a065ecad60d3a Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 13 Sep 2025 19:41:08 +0100 Subject: [PATCH] =?UTF-8?q?Use=20`TempDir()`=20in=20`CapturedStream`=20on?= =?UTF-8?q?=20all=20non=E2=80=90Windows=20platforms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is more consistent and makes tests using output capture behave as expected in environments with custom values of `$TEST_TMPDIR` or `$TMPDIR`, including fixing them in ones where `/tmp` may not be accessible, such as sandboxed build environments on macOS. --- googletest/src/gtest-port.cc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index f9f2fb582..7ada8a9b7 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -1076,13 +1076,7 @@ class CapturedStream { #else // There's no guarantee that a test has write access to the current // directory, so we create the temporary file in a temporary directory. - std::string name_template; - -#if defined(GTEST_OS_LINUX_ANDROID) || defined(GTEST_OS_IOS) - name_template = TempDir(); -#else - name_template = "/tmp/"; -#endif + std::string name_template = TempDir(); name_template.append("gtest_captured_stream.XXXXXX"); // mkstemp() modifies the string bytes in place, and does not go beyond the