summaryrefslogtreecommitdiffstats
path: root/googletest/src
diff options
context:
space:
mode:
authorDoug Greiman <dgreiman@google.com>2016-02-24 02:50:08 (GMT)
committerDoug Greiman <dgreiman@google.com>2016-02-24 02:50:08 (GMT)
commitd6790f26cae2ced1ebdd35f9fa61893e9cee1007 (patch)
treef2a380e296b920b1d4b975d1c71092a7f5a4a7ba /googletest/src
parentff5ffd457e032c8be8a64a7a94c824063c8b11e3 (diff)
downloadgoogletest-d6790f26cae2ced1ebdd35f9fa61893e9cee1007.zip
googletest-d6790f26cae2ced1ebdd35f9fa61893e9cee1007.tar.gz
googletest-d6790f26cae2ced1ebdd35f9fa61893e9cee1007.tar.bz2
Read Bazel's $XML_OUTPUT_FILE environment variable
If $XML_OUTPUT_FILE is set, and $GTEST_OUTPUT and --gtest_output are not specified, produce output as if GTEST_OUTPUT=xml:$XML_OUTPUT_FILE had been set.
Diffstat (limited to 'googletest/src')
-rw-r--r--googletest/src/gtest-port.cc19
-rw-r--r--googletest/src/gtest.cc2
2 files changed, 20 insertions, 1 deletions
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 0162fac..05ffca0 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -1235,5 +1235,24 @@ const char* StringFromGTestEnv(const char* flag, const char* default_value) {
return value == NULL ? default_value : value;
}
+// Reads and returns GTEST_OUTPUT and/or XML_OUTPUT_FILE environment
+// variables; if neither is set, returns default value.
+// XML_OUTPUT_FILE is set by the Bazel build system, and its format is
+// a filename without the "xml:" prefix of GTEST_OUTPUT.
+std::string OutputFromGTestEnv(const char* default_value) {
+#if defined(GTEST_GET_STRING_FROM_ENV_)
+ return GTEST_GET_STRING_FROM_ENV_("output", default_value);
+#endif // defined(GTEST_GET_STRING_FROM_ENV_)
+ const char* value = StringFromGTestEnv("output", NULL);
+ if (value) {
+ return value;
+ }
+ value = posix::GetEnv("XML_OUTPUT_FILE");
+ if (value) {
+ return std::string("xml:") + value;
+ }
+ return default_value;
+}
+
} // namespace internal
} // namespace testing
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 2bac245..5509f09 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -237,7 +237,7 @@ GTEST_DEFINE_bool_(list_tests, false,
GTEST_DEFINE_string_(
output,
- internal::StringFromGTestEnv("output", ""),
+ internal::OutputFromGTestEnv(""),
"A format (currently must be \"xml\"), optionally followed "
"by a colon and an output file name or directory. A directory "
"is indicated by a trailing pathname separator. "