From a901203eff9c7c8d70350c570390fe04da840778 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 24 Jul 2026 06:28:38 -0700 Subject: [PATCH] Display the Win32 error code when GetTempFileName() fails on Windows to aid debugging Closes: #4578 Fixes: #4566 PiperOrigin-RevId: 953335097 Change-Id: Ibc6ed3f2695cafb230e245dca625413f12536323 --- googletest/src/gtest-port.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index 4f4f2d8b2..433586f3b 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -1095,10 +1095,12 @@ class CapturedStream { 0, // Generate unique file name. temp_file_path); GTEST_CHECK_(success != 0) - << "Unable to create a temporary file in " << temp_dir_path; + << "Failed to create temporary file in " << temp_dir_path + << " with error " << ::GetLastError(); const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE); GTEST_CHECK_(captured_fd != -1) - << "Unable to open temporary file " << temp_file_path; + << "Failed to open temporary file " << temp_file_path << " with error " + << ::GetLastError(); filename_ = temp_file_path; #else // There's no guarantee that a test has write access to the current