diff --git a/3rdparty/googletest/googlemock/docs/CookBook.md b/3rdparty/googletest/googlemock/docs/CookBook.md index c215b55121e..c52f1009d1d 100644 --- a/3rdparty/googletest/googlemock/docs/CookBook.md +++ b/3rdparty/googletest/googlemock/docs/CookBook.md @@ -2103,7 +2103,7 @@ For better readability, Google Mock also gives you: * `WithArg(action)` (no `s` after `Arg`) when the inner `action` takes _one_ argument. As you may have realized, `InvokeWithoutArgs(...)` is just syntactic -sugar for `WithoutArgs(Inovke(...))`. +sugar for `WithoutArgs(Invoke(...))`. Here are more tips: diff --git a/3rdparty/googletest/googletest/docs/AdvancedGuide.md b/3rdparty/googletest/googletest/docs/AdvancedGuide.md index 7ba8d1219bd..93a65200dad 100644 --- a/3rdparty/googletest/googletest/docs/AdvancedGuide.md +++ b/3rdparty/googletest/googletest/docs/AdvancedGuide.md @@ -1571,15 +1571,14 @@ For technical reasons, there are some caveats: 1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot reference local non-static variables or non-static members of `this` object. 1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot return a value. -_Note:_ Google Test is designed with threads in mind. Once the +_Note:_ Google Test is designed with threads in mind. Once the synchronization primitives in `"gtest/internal/gtest-port.h"` have been implemented, Google Test will become thread-safe, meaning that -you can then use assertions in multiple threads concurrently. Before - -that, however, Google Test only supports single-threaded usage. Once +you can then use assertions in multiple threads concurrently. Before +that, however, Google Test only supports single-threaded usage. Once thread-safe, `EXPECT_FATAL_FAILURE()` and `EXPECT_NONFATAL_FAILURE()` will capture failures in the current thread only. If _statement_ -creates new threads, failures in these threads will be ignored. If +creates new threads, failures in these threads will be ignored. If you want to capture failures from all threads instead, you should use the following macros: diff --git a/3rdparty/googletest/googletest/include/gtest/internal/gtest-port.h b/3rdparty/googletest/googletest/include/gtest/internal/gtest-port.h index 7d6e4658194..0094ed5077e 100644 --- a/3rdparty/googletest/googletest/include/gtest/internal/gtest-port.h +++ b/3rdparty/googletest/googletest/include/gtest/internal/gtest-port.h @@ -2546,10 +2546,9 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value); // corresponding to the given Google Test flag. bool BoolFromGTestEnv(const char* flag, bool default_val); GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val); -const char* StringFromGTestEnv(const char* flag, const char* default_val); +std::string StringFromGTestEnv(const char* flag, const char* default_val); } // namespace internal } // namespace testing #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ - diff --git a/3rdparty/googletest/googletest/src/gtest-port.cc b/3rdparty/googletest/googletest/src/gtest-port.cc index 0162fac44be..e5bf3dd2be4 100644 --- a/3rdparty/googletest/googletest/src/gtest-port.cc +++ b/3rdparty/googletest/googletest/src/gtest-port.cc @@ -1226,13 +1226,33 @@ Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) { // Reads and returns the string environment variable corresponding to // the given flag; if it's not set, returns default_value. -const char* StringFromGTestEnv(const char* flag, const char* default_value) { +std::string StringFromGTestEnv(const char* flag, const char* default_value) { #if defined(GTEST_GET_STRING_FROM_ENV_) return GTEST_GET_STRING_FROM_ENV_(flag, default_value); #endif // defined(GTEST_GET_STRING_FROM_ENV_) const std::string env_var = FlagToEnvVar(flag); - const char* const value = posix::GetEnv(env_var.c_str()); - return value == NULL ? default_value : value; + const char* value = posix::GetEnv(env_var.c_str()); + if (value != NULL) { + return value; + } + + // As a special case for the 'output' flag, if GTEST_OUTPUT is not + // set, we look for XML_OUTPUT_FILE, which is set by the Bazel build + // system. The value of XML_OUTPUT_FILE is a filename without the + // "xml:" prefix of GTEST_OUTPUT. + // + // The net priority order after flag processing is thus: + // --gtest_output command line flag + // GTEST_OUTPUT environment variable + // XML_OUTPUT_FILE environment variable + // 'default_value' + if (strcmp(flag, "output") == 0) { + value = posix::GetEnv("XML_OUTPUT_FILE"); + if (value != NULL) { + return std::string("xml:") + value; + } + } + return default_value; } } // namespace internal diff --git a/3rdparty/googletest/googletest/test/gtest_env_var_test.py b/3rdparty/googletest/googletest/test/gtest_env_var_test.py index 1fc6ebe5f59..424075cfa37 100644 --- a/3rdparty/googletest/googletest/test/gtest_env_var_test.py +++ b/3rdparty/googletest/googletest/test/gtest_env_var_test.py @@ -87,6 +87,7 @@ class GTestEnvVarTest(gtest_test_utils.TestCase): TestFlag('break_on_failure', '1', '0') TestFlag('color', 'yes', 'auto') TestFlag('filter', 'FooTest.Bar', '*') + SetEnvVar('XML_OUTPUT_FILE', None) # For 'output' test TestFlag('output', 'xml:tmp/foo.xml', '') TestFlag('print_time', '0', '1') TestFlag('repeat', '999', '1') @@ -98,6 +99,19 @@ class GTestEnvVarTest(gtest_test_utils.TestCase): TestFlag('death_test_use_fork', '1', '0') TestFlag('stack_trace_depth', '0', '100') + def testXmlOutputFile(self): + """Tests that $XML_OUTPUT_FILE affects the output flag.""" + + SetEnvVar('GTEST_OUTPUT', None) + SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml') + AssertEq('xml:tmp/bar.xml', GetFlag('output')) + + def testXmlOutputFileOverride(self): + """Tests that $XML_OUTPUT_FILE is overridden by $GTEST_OUTPUT""" + + SetEnvVar('GTEST_OUTPUT', 'xml:tmp/foo.xml') + SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml') + AssertEq('xml:tmp/foo.xml', GetFlag('output')) if __name__ == '__main__': gtest_test_utils.Main()