@@ -451,6 +451,19 @@ static bool ShouldRunTestSuite(const TestSuite* test_suite) {
451
451
return test_suite->should_run ();
452
452
}
453
453
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
+
454
467
// AssertHelper constructor.
455
468
AssertHelper::AssertHelper (TestPartResult::Type type, const char * file,
456
469
int line, const char * message)
@@ -463,10 +476,7 @@ void AssertHelper::operator=(const Message& message) const {
463
476
UnitTest::GetInstance ()->AddTestPartResult (
464
477
data_->type , data_->file , data_->line ,
465
478
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 )
470
480
? UnitTest::GetInstance ()->impl ()->CurrentOsStackTraceExceptTop (1 )
471
481
: " "
472
482
// Skips the stack frame for this function itself.
0 commit comments