Display the Win32 error code when GetTempFileName() fails on Windows to aid debugging

Closes: #4578
Fixes: #4566
PiperOrigin-RevId: 953335097
Change-Id: Ibc6ed3f2695cafb230e245dca625413f12536323
This commit is contained in:
Abseil Team 2026-07-24 06:28:38 -07:00 committed by Copybara-Service
parent d4e2591485
commit a901203eff

View File

@ -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