Do not emit stack traces for messages generated by GTEST_SKIP()
Stack traces in assertion failures are an extremely useful tool for developers tasked with investigating failing tests. It's difficult to understate this. In contrast to ordinary test assertions (e.g., ASSERT_TRUE or EXPECT_FALSE), GTEST_SKIP is a developer-authored directive to skip one or more tests. Stack traces emitted in skip messages do not give the developer useful information, as the skip message itself contains the code location where GTEST_SKIP was used. In addition to being noise in the output, symbolization of stack traces is not free. In some Chromium configurations, symbolization in a skipped test can incur a cost in excess of 25 seconds for a test that otherwise takes 0-1ms; see https://crbug.com/1517343#c9. In this CL, we suppress generation and emission of stack traces for kSkip messages to reduce the output noise and overhead of GTEST_SKIP(). PiperOrigin-RevId: 598899010 Change-Id: I46926fed452c8d7edcb3d636d8fed42cb6c0a9e9
This commit is contained in:
parent
7c07a86369
commit
cfe5076a8b
@ -459,7 +459,12 @@ void AssertHelper::operator=(const Message& message) const {
|
||||
UnitTest::GetInstance()->AddTestPartResult(
|
||||
data_->type, data_->file, data_->line,
|
||||
AppendUserMessage(data_->message, message),
|
||||
UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1)
|
||||
// Suppress emission of the stack trace for GTEST_SKIP() since skipping is
|
||||
// an intentional act by the developer rather than a failure requiring
|
||||
// investigation.
|
||||
data_->type != TestPartResult::kSkip
|
||||
? UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1)
|
||||
: ""
|
||||
// Skips the stack frame for this function itself.
|
||||
); // NOLINT
|
||||
}
|
||||
|
@ -970,7 +970,6 @@ googletest-output-test_.cc:#: Skipped
|
||||
[0;32m[----------] [m1 test from TestSuiteThatSkipsInSetUp
|
||||
googletest-output-test_.cc:#: Skipped
|
||||
Skip entire test suite
|
||||
Stack trace: (omitted)
|
||||
|
||||
[0;32m[ RUN ] [mTestSuiteThatSkipsInSetUp.ShouldNotRun
|
||||
googletest-output-test_.cc:#: Skipped
|
||||
|
@ -112,20 +112,23 @@ Invalid characters in brackets []%(stack)s]]></failure>
|
||||
</testsuite>
|
||||
<testsuite name="SkippedTest" tests="3" failures="1" disabled="0" skipped="2" errors="0" time="*" timestamp="*">
|
||||
<testcase name="Skipped" status="run" file="gtest_xml_output_unittest_.cc" line="75" result="skipped" time="*" timestamp="*" classname="SkippedTest">
|
||||
<skipped message="gtest_xml_output_unittest_.cc:*
%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
|
||||
%(stack)s]]></skipped>
|
||||
<skipped message="gtest_xml_output_unittest_.cc:*

"><![CDATA[gtest_xml_output_unittest_.cc:*
|
||||
|
||||
]]></skipped>
|
||||
</testcase>
|
||||
<testcase name="SkippedWithMessage" file="gtest_xml_output_unittest_.cc" line="79" status="run" result="skipped" time="*" timestamp="*" classname="SkippedTest">
|
||||
<skipped message="gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
|
||||
It is good practice to tell why you skip a test.%(stack)s]]></skipped>
|
||||
<skipped message="gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.
"><![CDATA[gtest_xml_output_unittest_.cc:*
|
||||
It is good practice to tell why you skip a test.
|
||||
]]></skipped>
|
||||
</testcase>
|
||||
<testcase name="SkippedAfterFailure" file="gtest_xml_output_unittest_.cc" line="83" status="run" result="completed" time="*" timestamp="*" classname="SkippedTest">
|
||||
<failure message="gtest_xml_output_unittest_.cc:*
Expected equality of these values:
 1
 2%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
|
||||
Expected equality of these values:
|
||||
1
|
||||
2%(stack)s]]></failure>
|
||||
<skipped message="gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
|
||||
It is good practice to tell why you skip a test.%(stack)s]]></skipped>
|
||||
<skipped message="gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.
"><![CDATA[gtest_xml_output_unittest_.cc:*
|
||||
It is good practice to tell why you skip a test.
|
||||
]]></skipped>
|
||||
</testcase>
|
||||
|
||||
</testsuite>
|
||||
|
Loading…
Reference in New Issue
Block a user