From 2888f75afda49cb621979280b044174db5a5924f Mon Sep 17 00:00:00 2001 From: Dan Avram Date: Sun, 29 Oct 2023 21:11:59 +0200 Subject: [PATCH 1/2] [#4294] --gtest_break_on_failure conflicts with EXPECT_NONFATAL_FAILURE. --- googletest/src/gtest.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 99b22ed327..9a3113548e 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -5342,7 +5342,8 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type, result); if (result_type != TestPartResult::kSuccess && - result_type != TestPartResult::kSkip) { + result_type != TestPartResult::kSkip && + result_type != TestPartResult::kNonFatalFailure) { // gtest_break_on_failure takes precedence over // gtest_throw_on_failure. This allows a user to set the latter // in the code (perhaps in order to use Google Test assertions From 553c2d5dd77d1b6bd9d1442dc9d0b4b70253ab79 Mon Sep 17 00:00:00 2001 From: Dan Avram Date: Fri, 3 Nov 2023 18:40:23 +0200 Subject: [PATCH 2/2] [#4294] --gtest_break_on_failure updated condition to not effect throw_on_failure. Updated googletest-throw-on-failure-test_.cc to set the throw_on_failure mode. --- googletest/src/gtest.cc | 6 +++--- googletest/test/googletest-throw-on-failure-test_.cc | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 9a3113548e..f063a60e9d 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -5342,14 +5342,14 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type, result); if (result_type != TestPartResult::kSuccess && - result_type != TestPartResult::kSkip && - result_type != TestPartResult::kNonFatalFailure) { + result_type != TestPartResult::kSkip) { // gtest_break_on_failure takes precedence over // gtest_throw_on_failure. This allows a user to set the latter // in the code (perhaps in order to use Google Test assertions // with another testing framework) and specify the former on the // command line for debugging. - if (GTEST_FLAG_GET(break_on_failure)) { + if (GTEST_FLAG_GET(break_on_failure) && + result_type != TestPartResult::kNonFatalFailure) { #if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_PHONE) && \ !defined(GTEST_OS_WINDOWS_RT) // Using DebugBreak on Windows allows gtest to still break into a debugger diff --git a/googletest/test/googletest-throw-on-failure-test_.cc b/googletest/test/googletest-throw-on-failure-test_.cc index 3b81a5a1db..f388df6c5f 100644 --- a/googletest/test/googletest-throw-on-failure-test_.cc +++ b/googletest/test/googletest-throw-on-failure-test_.cc @@ -54,6 +54,7 @@ int main(int argc, char** argv) { std::set_terminate(&TerminateHandler); #endif testing::InitGoogleTest(&argc, argv); + GTEST_FLAG_SET(throw_on_failure, true); // We want to ensure that people can use Google Test assertions in // other testing frameworks, as long as they initialize Google Test