Skip to content

Commit

Permalink
[google#4294] --gtest_break_on_failure updated condition to not effec…
Browse files Browse the repository at this point in the history
…t throw_on_failure. Updated googletest-throw-on-failure-test_.cc to set the throw_on_failure mode.
  • Loading branch information
avrdan committed Nov 3, 2023
1 parent 2888f75 commit 2a0a129
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions googletest/src/gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5342,14 +5342,15 @@ 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/* &&
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
// 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
Expand Down
3 changes: 2 additions & 1 deletion googletest/test/googletest-throw-on-failure-test_.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -63,7 +64,7 @@ int main(int argc, char** argv) {

// In the throw-on-failure mode with exceptions disabled, this
// assertion will cause the program to exit with a non-zero code.
EXPECT_EQ(2, 3);
EXPECT_EQ(2, 3);

// When not in the throw-on-failure mode, the control will reach
// here.
Expand Down

0 comments on commit 2a0a129

Please sign in to comment.