@@ -451,6 +451,19 @@ static bool ShouldRunTestSuite(const TestSuite* test_suite) {
451451 return test_suite->should_run ();
452452}
453453
454+ namespace {
455+
456+ // Returns true if test part results of type `type` should include a stack
457+ // trace.
458+ bool ShouldEmitStackTraceForResultType (TestPartResult::Type type) {
459+ // Suppress emission of the stack trace for SUCCEED() since it likely never
460+ // requires investigation, and GTEST_SKIP() since skipping is an intentional
461+ // act by the developer rather than a failure requiring investigation.
462+ return type != TestPartResult::kSuccess && type != TestPartResult::kSkip ;
463+ }
464+
465+ } // namespace
466+
454467// AssertHelper constructor.
455468AssertHelper::AssertHelper (TestPartResult::Type type, const char * file,
456469 int line, const char * message)
@@ -463,10 +476,7 @@ void AssertHelper::operator=(const Message& message) const {
463476 UnitTest::GetInstance ()->AddTestPartResult (
464477 data_->type , data_->file , data_->line ,
465478 AppendUserMessage (data_->message , message),
466- // Suppress emission of the stack trace for GTEST_SKIP() since skipping is
467- // an intentional act by the developer rather than a failure requiring
468- // investigation.
469- data_->type != TestPartResult::kSkip
479+ ShouldEmitStackTraceForResultType (data_->type )
470480 ? UnitTest::GetInstance ()->impl ()->CurrentOsStackTraceExceptTop (1 )
471481 : " "
472482 // Skips the stack frame for this function itself.
0 commit comments