Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
51536300
Commit
51536300
authored
Nov 03, 2021
by
CJ Johnson
Browse files
Merge pull request #3638 from limitedAtonement:3637-disabled-output
PiperOrigin-RevId: 407356792
parents
cbf46d3f
3c958ac4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
googletest/include/gtest/gtest.h
googletest/include/gtest/gtest.h
+4
-0
googletest/src/gtest.cc
googletest/src/gtest.cc
+16
-5
No files found.
googletest/include/gtest/gtest.h
View file @
51536300
...
@@ -1123,6 +1123,9 @@ class TestEventListener {
...
@@ -1123,6 +1123,9 @@ class TestEventListener {
// Fired before the test starts.
// Fired before the test starts.
virtual
void
OnTestStart
(
const
TestInfo
&
test_info
)
=
0
;
virtual
void
OnTestStart
(
const
TestInfo
&
test_info
)
=
0
;
// Fired when a test is disabled
virtual
void
OnTestDisabled
(
const
TestInfo
&
test_info
)
{}
// Fired after a failed assertion or a SUCCEED() invocation.
// Fired after a failed assertion or a SUCCEED() invocation.
// If you want to throw an exception from this function to skip to the next
// If you want to throw an exception from this function to skip to the next
// TEST, it must be AssertionException defined above, or inherited from it.
// TEST, it must be AssertionException defined above, or inherited from it.
...
@@ -1172,6 +1175,7 @@ class EmptyTestEventListener : public TestEventListener {
...
@@ -1172,6 +1175,7 @@ class EmptyTestEventListener : public TestEventListener {
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void
OnTestStart
(
const
TestInfo
&
/*test_info*/
)
override
{}
void
OnTestStart
(
const
TestInfo
&
/*test_info*/
)
override
{}
void
OnTestDisabled
(
const
TestInfo
&
/*test_info*/
)
override
{}
void
OnTestPartResult
(
const
TestPartResult
&
/*test_part_result*/
)
override
{}
void
OnTestPartResult
(
const
TestPartResult
&
/*test_part_result*/
)
override
{}
void
OnTestEnd
(
const
TestInfo
&
/*test_info*/
)
override
{}
void
OnTestEnd
(
const
TestInfo
&
/*test_info*/
)
override
{}
void
OnTestSuiteEnd
(
const
TestSuite
&
/*test_suite*/
)
override
{}
void
OnTestSuiteEnd
(
const
TestSuite
&
/*test_suite*/
)
override
{}
...
...
googletest/src/gtest.cc
View file @
51536300
...
@@ -2855,20 +2855,20 @@ void UnitTestImpl::RegisterParameterizedTests() {
...
@@ -2855,20 +2855,20 @@ void UnitTestImpl::RegisterParameterizedTests() {
// Creates the test object, runs it, records its result, and then
// Creates the test object, runs it, records its result, and then
// deletes it.
// deletes it.
void
TestInfo
::
Run
()
{
void
TestInfo
::
Run
()
{
if
(
!
should_run_
)
return
;
TestEventListener
*
repeater
=
UnitTest
::
GetInstance
()
->
listeners
().
repeater
();
if
(
!
should_run_
)
{
if
(
is_disabled_
)
repeater
->
OnTestDisabled
(
*
this
);
return
;
}
// Tells UnitTest where to store test result.
// Tells UnitTest where to store test result.
internal
::
UnitTestImpl
*
const
impl
=
internal
::
GetUnitTestImpl
();
internal
::
UnitTestImpl
*
const
impl
=
internal
::
GetUnitTestImpl
();
impl
->
set_current_test_info
(
this
);
impl
->
set_current_test_info
(
this
);
TestEventListener
*
repeater
=
UnitTest
::
GetInstance
()
->
listeners
().
repeater
();
// Notifies the unit test event listeners that a test is about to start.
// Notifies the unit test event listeners that a test is about to start.
repeater
->
OnTestStart
(
*
this
);
repeater
->
OnTestStart
(
*
this
);
result_
.
set_start_timestamp
(
internal
::
GetTimeInMillis
());
result_
.
set_start_timestamp
(
internal
::
GetTimeInMillis
());
internal
::
Timer
timer
;
internal
::
Timer
timer
;
impl
->
os_stack_trace_getter
()
->
UponLeavingGTest
();
impl
->
os_stack_trace_getter
()
->
UponLeavingGTest
();
// Creates the test object.
// Creates the test object.
...
@@ -3396,6 +3396,7 @@ class PrettyUnitTestResultPrinter : public TestEventListener {
...
@@ -3396,6 +3396,7 @@ class PrettyUnitTestResultPrinter : public TestEventListener {
#endif // OnTestCaseStart
#endif // OnTestCaseStart
void
OnTestStart
(
const
TestInfo
&
test_info
)
override
;
void
OnTestStart
(
const
TestInfo
&
test_info
)
override
;
void
OnTestDisabled
(
const
TestInfo
&
test_info
)
override
;
void
OnTestPartResult
(
const
TestPartResult
&
result
)
override
;
void
OnTestPartResult
(
const
TestPartResult
&
result
)
override
;
void
OnTestEnd
(
const
TestInfo
&
test_info
)
override
;
void
OnTestEnd
(
const
TestInfo
&
test_info
)
override
;
...
@@ -3495,6 +3496,13 @@ void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
...
@@ -3495,6 +3496,13 @@ void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
fflush
(
stdout
);
fflush
(
stdout
);
}
}
void
PrettyUnitTestResultPrinter
::
OnTestDisabled
(
const
TestInfo
&
test_info
)
{
ColoredPrintf
(
GTestColor
::
kYellow
,
"[ DISABLED ] "
);
PrintTestName
(
test_info
.
test_suite_name
(),
test_info
.
name
());
printf
(
"
\n
"
);
fflush
(
stdout
);
}
// Called after an assertion failure.
// Called after an assertion failure.
void
PrettyUnitTestResultPrinter
::
OnTestPartResult
(
void
PrettyUnitTestResultPrinter
::
OnTestPartResult
(
const
TestPartResult
&
result
)
{
const
TestPartResult
&
result
)
{
...
@@ -3697,6 +3705,7 @@ class BriefUnitTestResultPrinter : public TestEventListener {
...
@@ -3697,6 +3705,7 @@ class BriefUnitTestResultPrinter : public TestEventListener {
#endif // OnTestCaseStart
#endif // OnTestCaseStart
void
OnTestStart
(
const
TestInfo
&
/*test_info*/
)
override
{}
void
OnTestStart
(
const
TestInfo
&
/*test_info*/
)
override
{}
void
OnTestDisabled
(
const
TestInfo
&
/*test_info*/
)
override
{}
void
OnTestPartResult
(
const
TestPartResult
&
result
)
override
;
void
OnTestPartResult
(
const
TestPartResult
&
result
)
override
;
void
OnTestEnd
(
const
TestInfo
&
test_info
)
override
;
void
OnTestEnd
(
const
TestInfo
&
test_info
)
override
;
...
@@ -3803,6 +3812,7 @@ class TestEventRepeater : public TestEventListener {
...
@@ -3803,6 +3812,7 @@ class TestEventRepeater : public TestEventListener {
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void
OnTestSuiteStart
(
const
TestSuite
&
parameter
)
override
;
void
OnTestSuiteStart
(
const
TestSuite
&
parameter
)
override
;
void
OnTestStart
(
const
TestInfo
&
test_info
)
override
;
void
OnTestStart
(
const
TestInfo
&
test_info
)
override
;
void
OnTestDisabled
(
const
TestInfo
&
test_info
)
override
;
void
OnTestPartResult
(
const
TestPartResult
&
result
)
override
;
void
OnTestPartResult
(
const
TestPartResult
&
result
)
override
;
void
OnTestEnd
(
const
TestInfo
&
test_info
)
override
;
void
OnTestEnd
(
const
TestInfo
&
test_info
)
override
;
// Legacy API is deprecated but still available
// Legacy API is deprecated but still available
...
@@ -3873,6 +3883,7 @@ GTEST_REPEATER_METHOD_(OnTestCaseStart, TestSuite)
...
@@ -3873,6 +3883,7 @@ GTEST_REPEATER_METHOD_(OnTestCaseStart, TestSuite)
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
GTEST_REPEATER_METHOD_
(
OnTestSuiteStart
,
TestSuite
)
GTEST_REPEATER_METHOD_
(
OnTestSuiteStart
,
TestSuite
)
GTEST_REPEATER_METHOD_
(
OnTestStart
,
TestInfo
)
GTEST_REPEATER_METHOD_
(
OnTestStart
,
TestInfo
)
GTEST_REPEATER_METHOD_
(
OnTestDisabled
,
TestInfo
)
GTEST_REPEATER_METHOD_
(
OnTestPartResult
,
TestPartResult
)
GTEST_REPEATER_METHOD_
(
OnTestPartResult
,
TestPartResult
)
GTEST_REPEATER_METHOD_
(
OnEnvironmentsTearDownStart
,
UnitTest
)
GTEST_REPEATER_METHOD_
(
OnEnvironmentsTearDownStart
,
UnitTest
)
GTEST_REVERSE_REPEATER_METHOD_
(
OnEnvironmentsSetUpEnd
,
UnitTest
)
GTEST_REVERSE_REPEATER_METHOD_
(
OnEnvironmentsSetUpEnd
,
UnitTest
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment