Sounds good to me. Revised patch:
commit c100f7501ccc63817b6ba99f3915b54963b49a27
Author: Brian Silverman <
bsilve...@gmail.com>
Date: Sat Sep 12 14:31:41 2015 -0400
Add an environment variable to control the location of temporary files
Bazel says in their test environment documentation
(
http://bazel.io/docs/test-encyclopedia.html) that tests should not
write to /tmp. However, googletest unconditionally writes files there.
This fixes that by having googletest use the GTEST_TMP_DIR
environment variable instead, which is easy to have Bazel set when
running tests.
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 3842c41..8f3fc82 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -953,7 +953,15 @@ class CapturedStream {
// use /sdcard.
char name_template[] = "/sdcard/gtest_captured_stream.XXXXXX";
# else
- char name_template[] = "/tmp/captured_stream.XXXXXX";
+ char name_template[256];
+ char *test_tmpdir = getenv("GTEST_TMP_DIR");
+ if (test_tmpdir != NULL && test_tmpdir[0] != '\0') {
+ snprintf(name_template, sizeof(name_template),
+ "%s/captured_stream.XXXXXX", test_tmpdir);
+ } else {
+ const char *default_template = "/tmp/captured_stream.XXXXXX";
+ strcpy(name_template, default_template);
+ }
# endif // GTEST_OS_LINUX_ANDROID
const int captured_fd = mkstemp(name_template);
filename_ = name_template;