diff options
author | 2017-01-30 08:38:23 +0000 | |
---|---|---|
committer | 2017-01-30 09:03:19 +0000 | |
commit | 98cafe88f9b6eee6b56ba0b6cdbe7acc4e0adf04 (patch) | |
tree | d34618285b3d291b03714c72bd2b516e1233b826 /src/test/cpp | |
parent | df6bbec11832ad48af1ce92a85dc25f1da5ac67a (diff) |
Fix //src/test/cpp/util:logging_test on Windows
Set $TMP to $TEST_TMPDIR, so that the
CaptureStderr can safely call SetTempPathA and not
get C:\Windows\ back as a result, which is
unfortunately read-only.
See https://github.com/bazelbuild/bazel/issues/2107
--
Change-Id: If63cb028f677d9a0d9597f83afc9e08f2e5d2529
Reviewed-on: https://cr.bazel.build/8494
PiperOrigin-RevId: 145961529
MOS_MIGRATED_REVID=145961529
Diffstat (limited to 'src/test/cpp')
-rw-r--r-- | src/test/cpp/util/BUILD | 1 | ||||
-rw-r--r-- | src/test/cpp/util/logging_test.cc | 15 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/test/cpp/util/BUILD b/src/test/cpp/util/BUILD index 80e69b7267..4328bf6511 100644 --- a/src/test/cpp/util/BUILD +++ b/src/test/cpp/util/BUILD @@ -43,6 +43,7 @@ cc_test( name = "logging_test", srcs = ["logging_test.cc"], deps = [ + "//src/main/cpp:blaze_util", "//src/main/cpp/util:bazel_log_handler", "//src/main/cpp/util:logging", "//third_party:gtest", diff --git a/src/test/cpp/util/logging_test.cc b/src/test/cpp/util/logging_test.cc index 1f7c6cd585..3288bdf0a2 100644 --- a/src/test/cpp/util/logging_test.cc +++ b/src/test/cpp/util/logging_test.cc @@ -15,6 +15,7 @@ #include <memory> #include <string> +#include "src/main/cpp/blaze_util_platform.h" #include "src/main/cpp/util/bazel_log_handler.h" #include "src/main/cpp/util/logging.h" #include "gtest/gtest.h" @@ -22,7 +23,12 @@ namespace blaze_util { TEST(LoggingTest, BazelLogHandlerDumpsToCerrAtFail) { - // Set up logging and be prepared to capture stderr at destruction. + // Set the value of $TMP first, because CaptureStderr retrieves a temp + // directory path and on Windows, the corresponding function (GetTempPathA) + // reads $TMP. + blaze::SetEnv("TMP", blaze::GetEnv("TEST_TMPDIR")); + // Set up logging now that $TMP is set, and be prepared to capture stderr at + // destruction. testing::internal::CaptureStderr(); std::unique_ptr<blaze_util::BazelLogHandler> handler( new blaze_util::BazelLogHandler()); @@ -51,7 +57,12 @@ TEST(LoggingTest, LogLevelNamesMatch) { } TEST(LoggingTest, ImpossibleFile) { - // Set up to capture logging to stderr. + // Set the value of $TMP first, because CaptureStderr retrieves a temp + // directory path and on Windows, the corresponding function (GetTempPathA) + // reads $TMP. + blaze::SetEnv("TMP", blaze::GetEnv("TEST_TMPDIR")); + // Set up logging now that $TMP is set, and be prepared to capture stderr at + // destruction. testing::internal::CaptureStderr(); std::unique_ptr<blaze_util::BazelLogHandler> handler( new blaze_util::BazelLogHandler()); |