From d7a6757c8173a5bbcb66b48d4646af6b087db066 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Sun, 16 Jul 2023 09:35:54 +0100 Subject: [PATCH] deps: update googletest to cc36671 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/48789 Reviewed-By: Luigi Pinca Reviewed-By: Moshe Atlow Reviewed-By: Michaël Zasso --- .../googletest/include/gtest/gtest-printers.h | 12 ++-- .../include/gtest/internal/gtest-port-arch.h | 2 + .../include/gtest/internal/gtest-port.h | 11 +-- deps/googletest/src/gtest-filepath.cc | 4 +- deps/googletest/src/gtest-internal-inl.h | 6 +- deps/googletest/src/gtest-printers.cc | 8 +-- deps/googletest/src/gtest.cc | 70 ++++++++----------- .../maintaining/maintaining-dependencies.md | 6 +- 8 files changed, 55 insertions(+), 64 deletions(-) diff --git a/deps/googletest/include/gtest/gtest-printers.h b/deps/googletest/include/gtest/gtest-printers.h index 539d99c405d291..1ba5178e15d4a7 100644 --- a/deps/googletest/include/gtest/gtest-printers.h +++ b/deps/googletest/include/gtest/gtest-printers.h @@ -298,8 +298,8 @@ struct FindFirstPrinter< // - Print containers (they have begin/end/etc). // - Print function pointers. // - Print object pointers. -// - Use the stream operator, if available. // - Print protocol buffers. +// - Use the stream operator, if available. // - Print types convertible to BiggestInt. // - Print types convertible to StringView, if available. // - Fallback to printing the raw bytes of the object. @@ -475,7 +475,7 @@ GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os); inline void PrintTo(char16_t c, ::std::ostream* os) { PrintTo(ImplicitCast_(c), os); } -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t inline void PrintTo(char8_t c, ::std::ostream* os) { PrintTo(ImplicitCast_(c), os); } @@ -531,7 +531,7 @@ int AppropriateResolution(FloatType val) { } else if (val >= 0.0001) { mulfor6 = 1e9; } - if (static_cast(static_cast(val * mulfor6 + 0.5)) / + if (static_cast(static_cast(val * mulfor6 + 0.5)) / mulfor6 == val) return 6; @@ -546,7 +546,7 @@ int AppropriateResolution(FloatType val) { } else if (val >= 1e6) { // 1,000,000 to 9,999,999 divfor6 = 10; } - if (static_cast(static_cast(val / divfor6 + 0.5)) * + if (static_cast(static_cast(val / divfor6 + 0.5)) * divfor6 == val) return 6; @@ -588,7 +588,7 @@ inline void PrintTo(const unsigned char* s, ::std::ostream* os) { inline void PrintTo(unsigned char* s, ::std::ostream* os) { PrintTo(ImplicitCast_(s), os); } -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t // Overloads for u8 strings. GTEST_API_ void PrintTo(const char8_t* s, ::std::ostream* os); inline void PrintTo(char8_t* s, ::std::ostream* os) { @@ -908,7 +908,7 @@ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) { GTEST_API_ void UniversalPrintArray(const char* begin, size_t len, ::std::ostream* os); -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t // This overload prints a (const) char8_t array compactly. GTEST_API_ void UniversalPrintArray(const char8_t* begin, size_t len, ::std::ostream* os); diff --git a/deps/googletest/include/gtest/internal/gtest-port-arch.h b/deps/googletest/include/gtest/internal/gtest-port-arch.h index 04064606f5d02b..34964932d40f5f 100644 --- a/deps/googletest/include/gtest/internal/gtest-port-arch.h +++ b/deps/googletest/include/gtest/internal/gtest-port-arch.h @@ -113,6 +113,8 @@ #define GTEST_OS_XTENSA 1 #elif defined(__hexagon__) #define GTEST_OS_QURT 1 +#elif defined(CPU_QN9090) || defined(CPU_QN9090HN) +#define GTEST_OS_NXP_QN9090 1 #endif // __CYGWIN__ #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ diff --git a/deps/googletest/include/gtest/internal/gtest-port.h b/deps/googletest/include/gtest/internal/gtest-port.h index d71110c0c006cf..26e4cc3d378f9d 100644 --- a/deps/googletest/include/gtest/internal/gtest-port.h +++ b/deps/googletest/include/gtest/internal/gtest-port.h @@ -505,7 +505,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #if (!(defined(GTEST_OS_LINUX_ANDROID) || defined(GTEST_OS_CYGWIN) || \ defined(GTEST_OS_SOLARIS) || defined(GTEST_OS_HAIKU) || \ defined(GTEST_OS_ESP32) || defined(GTEST_OS_ESP8266) || \ - defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT))) + defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) || \ + defined(GTEST_OS_NXP_QN9090))) #define GTEST_HAS_STD_WSTRING 1 #else #define GTEST_HAS_STD_WSTRING 0 @@ -924,9 +925,11 @@ using std::tuple_size; namespace internal { // A secret type that Google Test users don't know about. It has no -// definition on purpose. Therefore it's impossible to create a +// accessible constructors on purpose. Therefore it's impossible to create a // Secret object, which is what we want. -class Secret; +class Secret { + Secret(const Secret&) = delete; +}; // A helper for suppressing warnings on constant condition. It just // returns 'condition'. @@ -1995,7 +1998,7 @@ inline bool IsUpper(char ch) { inline bool IsXDigit(char ch) { return isxdigit(static_cast(ch)) != 0; } -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t inline bool IsXDigit(char8_t ch) { return isxdigit(static_cast(ch)) != 0; } diff --git a/deps/googletest/src/gtest-filepath.cc b/deps/googletest/src/gtest-filepath.cc index 75f52bcfc0f996..1d30c95646c5b0 100644 --- a/deps/googletest/src/gtest-filepath.cc +++ b/deps/googletest/src/gtest-filepath.cc @@ -102,7 +102,7 @@ FilePath FilePath::GetCurrentDir() { #if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \ defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) || \ defined(GTEST_OS_ESP32) || defined(GTEST_OS_XTENSA) || \ - defined(GTEST_OS_QURT) + defined(GTEST_OS_QURT) || defined(GTEST_OS_NXP_QN9090) // These platforms do not have a current directory, so we just return // something reasonable. return FilePath(kCurrentDirectoryString); @@ -356,7 +356,7 @@ bool FilePath::CreateFolder() const { #elif defined(GTEST_OS_WINDOWS) int result = _mkdir(pathname_.c_str()); #elif defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \ - defined(GTEST_OS_QURT) + defined(GTEST_OS_QURT) || defined(GTEST_OS_NXP_QN9090) // do nothing int result = 0; #else diff --git a/deps/googletest/src/gtest-internal-inl.h b/deps/googletest/src/gtest-internal-inl.h index be821662c18887..1e9b5c266dd67c 100644 --- a/deps/googletest/src/gtest-internal-inl.h +++ b/deps/googletest/src/gtest-internal-inl.h @@ -387,10 +387,10 @@ class GTEST_API_ UnitTestOptions { #ifdef GTEST_OS_WINDOWS // Function for supporting the gtest_catch_exception flag. - // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the - // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise. + // Returns EXCEPTION_EXECUTE_HANDLER if given SEH exception was handled, or + // EXCEPTION_CONTINUE_SEARCH otherwise. // This function is useful as an __except condition. - static int GTestShouldProcessSEH(DWORD exception_code); + static int GTestProcessSEH(DWORD seh_code, const char* location); #endif // GTEST_OS_WINDOWS // Returns true if "name" matches the ':' separated list of glob-style diff --git a/deps/googletest/src/gtest-printers.cc b/deps/googletest/src/gtest-printers.cc index 2b470678249824..e3acecba8e4dec 100644 --- a/deps/googletest/src/gtest-printers.cc +++ b/deps/googletest/src/gtest-printers.cc @@ -216,7 +216,7 @@ static const char* GetCharWidthPrefix(signed char) { return ""; } static const char* GetCharWidthPrefix(unsigned char) { return ""; } -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t static const char* GetCharWidthPrefix(char8_t) { return "u8"; } #endif @@ -232,7 +232,7 @@ static CharFormat PrintAsStringLiteralTo(char c, ostream* os) { return PrintAsStringLiteralTo(ToChar32(c), os); } -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t static CharFormat PrintAsStringLiteralTo(char8_t c, ostream* os) { return PrintAsStringLiteralTo(ToChar32(c), os); } @@ -395,7 +395,7 @@ void UniversalPrintArray(const char* begin, size_t len, ostream* os) { UniversalPrintCharArray(begin, len, os); } -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t // Prints a (const) char8_t array of 'len' elements, starting at address // 'begin'. void UniversalPrintArray(const char8_t* begin, size_t len, ostream* os) { @@ -438,7 +438,7 @@ void PrintCStringTo(const Char* s, ostream* os) { void PrintTo(const char* s, ostream* os) { PrintCStringTo(s, os); } -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t void PrintTo(const char8_t* s, ostream* os) { PrintCStringTo(s, os); } #endif diff --git a/deps/googletest/src/gtest.cc b/deps/googletest/src/gtest.cc index d9fd27709a65f1..30a5cc3f83a7e0 100644 --- a/deps/googletest/src/gtest.cc +++ b/deps/googletest/src/gtest.cc @@ -863,13 +863,18 @@ bool UnitTestOptions::FilterMatchesTest(const std::string& test_suite_name, } #if GTEST_HAS_SEH -// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the -// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise. -// This function is useful as an __except condition. -int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) { +static std::string FormatSehExceptionMessage(DWORD exception_code, + const char* location) { + Message message; + message << "SEH exception with code 0x" << std::setbase(16) << exception_code + << std::setbase(10) << " thrown in " << location << "."; + return message.GetString(); +} + +int UnitTestOptions::GTestProcessSEH(DWORD seh_code, const char* location) { // Google Test should handle a SEH exception if: // 1. the user wants it to, AND - // 2. this is not a breakpoint exception, AND + // 2. this is not a breakpoint exception or stack overflow, AND // 3. this is not a C++ exception (VC++ implements them via SEH, // apparently). // @@ -877,16 +882,20 @@ int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) { // (see http://support.microsoft.com/kb/185294 for more information). const DWORD kCxxExceptionCode = 0xe06d7363; - bool should_handle = true; + if (!GTEST_FLAG_GET(catch_exceptions) || seh_code == kCxxExceptionCode || + seh_code == EXCEPTION_BREAKPOINT || + seh_code == EXCEPTION_STACK_OVERFLOW) { + return EXCEPTION_CONTINUE_SEARCH; // Don't handle these exceptions + } - if (!GTEST_FLAG_GET(catch_exceptions)) - should_handle = false; - else if (exception_code == EXCEPTION_BREAKPOINT) - should_handle = false; - else if (exception_code == kCxxExceptionCode) - should_handle = false; + internal::ReportFailureInUnknownLocation( + TestPartResult::kFatalFailure, + FormatSehExceptionMessage(seh_code, location) + + "\n" + "Stack trace:\n" + + ::testing::internal::GetCurrentOsStackTraceExceptTop(1)); - return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH; + return EXCEPTION_EXECUTE_HANDLER; } #endif // GTEST_HAS_SEH @@ -2553,23 +2562,6 @@ bool Test::HasSameFixtureClass() { return true; } -#if GTEST_HAS_SEH - -// Adds an "exception thrown" fatal failure to the current test. This -// function returns its result via an output parameter pointer because VC++ -// prohibits creation of objects with destructors on stack in functions -// using __try (see error C2712). -static std::string* FormatSehExceptionMessage(DWORD exception_code, - const char* location) { - Message message; - message << "SEH exception with code 0x" << std::setbase(16) << exception_code - << std::setbase(10) << " thrown in " << location << "."; - - return new std::string(message.GetString()); -} - -#endif // GTEST_HAS_SEH - namespace internal { #if GTEST_HAS_EXCEPTIONS @@ -2611,16 +2603,8 @@ Result HandleSehExceptionsInMethodIfSupported(T* object, Result (T::*method)(), #if GTEST_HAS_SEH __try { return (object->*method)(); - } __except (internal::UnitTestOptions::GTestShouldProcessSEH( // NOLINT - GetExceptionCode())) { - // We create the exception message on the heap because VC++ prohibits - // creation of objects with destructors on stack in functions using __try - // (see error C2712). - std::string* exception_message = - FormatSehExceptionMessage(GetExceptionCode(), location); - internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure, - *exception_message); - delete exception_message; + } __except (internal::UnitTestOptions::GTestProcessSEH( // NOLINT + GetExceptionCode(), location)) { return static_cast(0); } #else @@ -5655,8 +5639,10 @@ void UnitTestImpl::ConfigureXmlOutput() { << output_format << "\" ignored."; } #else - GTEST_LOG_(ERROR) << "ERROR: alternative output formats require " - << "GTEST_HAS_FILE_SYSTEM to be enabled"; + if (!output_format.empty()) { + GTEST_LOG_(ERROR) << "ERROR: alternative output formats require " + << "GTEST_HAS_FILE_SYSTEM to be enabled"; + } #endif // GTEST_HAS_FILE_SYSTEM } diff --git a/doc/contributing/maintaining/maintaining-dependencies.md b/doc/contributing/maintaining/maintaining-dependencies.md index 7f28a17d5ed916..4d3f96babb12fa 100644 --- a/doc/contributing/maintaining/maintaining-dependencies.md +++ b/doc/contributing/maintaining/maintaining-dependencies.md @@ -15,7 +15,7 @@ This a list of all the dependencies: * [c-ares 1.19.0][] * [cjs-module-lexer 1.2.2][] * [corepack][] -* [googletest ec4fed9][] +* [googletest cc36671][] * [histogram 0.11.8][] * [icu-small 73.2][] * [libuv 1.46.0][] @@ -189,7 +189,7 @@ In practical terms, Corepack will let you use Yarn and pnpm without having to install them - just like what currently happens with npm, which is shipped by Node.js by default. -### googletest ec4fed9 +### googletest cc36671 The [googletest](https://github.com/google/googletest) dependency is Google’s C++ testing and mocking framework. @@ -326,7 +326,7 @@ performance improvements not currently available in standard zlib. [cjs-module-lexer 1.2.2]: #cjs-module-lexer-122 [corepack]: #corepack [dependency-update-action]: ../../../.github/workflows/tools.yml -[googletest ec4fed9]: #googletest-ec4fed9 +[googletest cc36671]: #googletest-cc36671 [histogram 0.11.8]: #histogram-0118 [icu-small 73.2]: #icu-small-732 [libuv 1.46.0]: #libuv-1460