Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
07beabd6
Commit
07beabd6
authored
May 28, 2020
by
Derek Mauro
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2767 from mvoorsluys:OutputXmlSkipped
PiperOrigin-RevId: 313386267
parents
8f3854e2
7c8ab528
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
13 deletions
+70
-13
gtest.cc
googletest/src/gtest.cc
+27
-6
googletest-json-output-unittest.py
googletest/test/googletest-json-output-unittest.py
+30
-4
gtest_xml_outfiles_test.py
googletest/test/gtest_xml_outfiles_test.py
+2
-2
gtest_xml_output_unittest.py
googletest/test/gtest_xml_output_unittest.py
+0
-0
gtest_xml_output_unittest_.cc
googletest/test/gtest_xml_output_unittest_.cc
+9
-0
gtest_xml_test_utils.py
googletest/test/gtest_xml_test_utils.py
+2
-1
No files found.
googletest/src/gtest.cc
View file @
07beabd6
...
@@ -2194,7 +2194,9 @@ std::string AppendUserMessage(const std::string& gtest_msg,
...
@@ -2194,7 +2194,9 @@ std::string AppendUserMessage(const std::string& gtest_msg,
if
(
user_msg_string
.
empty
())
{
if
(
user_msg_string
.
empty
())
{
return
gtest_msg
;
return
gtest_msg
;
}
}
if
(
gtest_msg
.
empty
())
{
return
user_msg_string
;
}
return
gtest_msg
+
"
\n
"
+
user_msg_string
;
return
gtest_msg
+
"
\n
"
+
user_msg_string
;
}
}
...
@@ -2273,7 +2275,8 @@ static const char* const kReservedTestSuitesAttributes[] = {
...
@@ -2273,7 +2275,8 @@ static const char* const kReservedTestSuitesAttributes[] = {
// The list of reserved attributes used in the <testsuite> element of XML
// The list of reserved attributes used in the <testsuite> element of XML
// output.
// output.
static
const
char
*
const
kReservedTestSuiteAttributes
[]
=
{
static
const
char
*
const
kReservedTestSuiteAttributes
[]
=
{
"disabled"
,
"errors"
,
"failures"
,
"name"
,
"tests"
,
"time"
,
"timestamp"
};
"disabled"
,
"errors"
,
"failures"
,
"name"
,
"tests"
,
"time"
,
"timestamp"
,
"skipped"
};
// The list of reserved attributes used in the <testcase> element of XML output.
// The list of reserved attributes used in the <testcase> element of XML output.
static
const
char
*
const
kReservedTestCaseAttributes
[]
=
{
static
const
char
*
const
kReservedTestCaseAttributes
[]
=
{
...
@@ -3115,7 +3118,7 @@ static std::string FormatTestSuiteCount(int test_suite_count) {
...
@@ -3115,7 +3118,7 @@ static std::string FormatTestSuiteCount(int test_suite_count) {
static
const
char
*
TestPartResultTypeToString
(
TestPartResult
::
Type
type
)
{
static
const
char
*
TestPartResultTypeToString
(
TestPartResult
::
Type
type
)
{
switch
(
type
)
{
switch
(
type
)
{
case
TestPartResult
:
:
kSkip
:
case
TestPartResult
:
:
kSkip
:
return
"Skipped"
;
return
"Skipped
\n
"
;
case
TestPartResult
:
:
kSuccess
:
case
TestPartResult
:
:
kSuccess
:
return
"Success"
;
return
"Success"
;
...
@@ -4187,10 +4190,11 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
...
@@ -4187,10 +4190,11 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
OutputXmlAttribute
(
stream
,
kTestsuite
,
"classname"
,
test_suite_name
);
OutputXmlAttribute
(
stream
,
kTestsuite
,
"classname"
,
test_suite_name
);
int
failures
=
0
;
int
failures
=
0
;
int
skips
=
0
;
for
(
int
i
=
0
;
i
<
result
.
total_part_count
();
++
i
)
{
for
(
int
i
=
0
;
i
<
result
.
total_part_count
();
++
i
)
{
const
TestPartResult
&
part
=
result
.
GetTestPartResult
(
i
);
const
TestPartResult
&
part
=
result
.
GetTestPartResult
(
i
);
if
(
part
.
failed
())
{
if
(
part
.
failed
())
{
if
(
++
failures
==
1
)
{
if
(
++
failures
==
1
&&
skips
==
0
)
{
*
stream
<<
">
\n
"
;
*
stream
<<
">
\n
"
;
}
}
const
std
::
string
location
=
const
std
::
string
location
=
...
@@ -4203,13 +4207,26 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
...
@@ -4203,13 +4207,26 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
const
std
::
string
detail
=
location
+
"
\n
"
+
part
.
message
();
const
std
::
string
detail
=
location
+
"
\n
"
+
part
.
message
();
OutputXmlCDataSection
(
stream
,
RemoveInvalidXmlCharacters
(
detail
).
c_str
());
OutputXmlCDataSection
(
stream
,
RemoveInvalidXmlCharacters
(
detail
).
c_str
());
*
stream
<<
"</failure>
\n
"
;
*
stream
<<
"</failure>
\n
"
;
}
else
if
(
part
.
skipped
())
{
if
(
++
skips
==
1
&&
failures
==
0
)
{
*
stream
<<
">
\n
"
;
}
const
std
::
string
location
=
internal
::
FormatCompilerIndependentFileLocation
(
part
.
file_name
(),
part
.
line_number
());
const
std
::
string
summary
=
location
+
"
\n
"
+
part
.
summary
();
*
stream
<<
" <skipped message=
\"
"
<<
EscapeXmlAttribute
(
summary
.
c_str
())
<<
"
\"
>"
;
const
std
::
string
detail
=
location
+
"
\n
"
+
part
.
message
();
OutputXmlCDataSection
(
stream
,
RemoveInvalidXmlCharacters
(
detail
).
c_str
());
*
stream
<<
"</skipped>
\n
"
;
}
}
}
}
if
(
failures
==
0
&&
result
.
test_property_count
()
==
0
)
{
if
(
failures
==
0
&&
skips
==
0
&&
result
.
test_property_count
()
==
0
)
{
*
stream
<<
" />
\n
"
;
*
stream
<<
" />
\n
"
;
}
else
{
}
else
{
if
(
failures
==
0
)
{
if
(
failures
==
0
&&
skips
==
0
)
{
*
stream
<<
">
\n
"
;
*
stream
<<
">
\n
"
;
}
}
OutputXmlTestProperties
(
stream
,
result
);
OutputXmlTestProperties
(
stream
,
result
);
...
@@ -4231,7 +4248,11 @@ void XmlUnitTestResultPrinter::PrintXmlTestSuite(std::ostream* stream,
...
@@ -4231,7 +4248,11 @@ void XmlUnitTestResultPrinter::PrintXmlTestSuite(std::ostream* stream,
OutputXmlAttribute
(
OutputXmlAttribute
(
stream
,
kTestsuite
,
"disabled"
,
stream
,
kTestsuite
,
"disabled"
,
StreamableToString
(
test_suite
.
reportable_disabled_test_count
()));
StreamableToString
(
test_suite
.
reportable_disabled_test_count
()));
OutputXmlAttribute
(
stream
,
kTestsuite
,
"skipped"
,
StreamableToString
(
test_suite
.
skipped_test_count
()));
OutputXmlAttribute
(
stream
,
kTestsuite
,
"errors"
,
"0"
);
OutputXmlAttribute
(
stream
,
kTestsuite
,
"errors"
,
"0"
);
OutputXmlAttribute
(
stream
,
kTestsuite
,
"time"
,
OutputXmlAttribute
(
stream
,
kTestsuite
,
"time"
,
FormatTimeInMillisAsSeconds
(
test_suite
.
elapsed_time
()));
FormatTimeInMillisAsSeconds
(
test_suite
.
elapsed_time
()));
OutputXmlAttribute
(
OutputXmlAttribute
(
...
...
googletest/test/googletest-json-output-unittest.py
View file @
07beabd6
...
@@ -58,9 +58,9 @@ else:
...
@@ -58,9 +58,9 @@ else:
EXPECTED_NON_EMPTY
=
{
EXPECTED_NON_EMPTY
=
{
u'tests'
:
u'tests'
:
2
4
,
2
6
,
u'failures'
:
u'failures'
:
4
,
5
,
u'disabled'
:
u'disabled'
:
2
,
2
,
u'errors'
:
u'errors'
:
...
@@ -158,9 +158,9 @@ EXPECTED_NON_EMPTY = {
...
@@ -158,9 +158,9 @@ EXPECTED_NON_EMPTY = {
u'name'
:
u'name'
:
u'SkippedTest'
,
u'SkippedTest'
,
u'tests'
:
u'tests'
:
1
,
3
,
u'failures'
:
u'failures'
:
0
,
1
,
u'disabled'
:
u'disabled'
:
0
,
0
,
u'errors'
:
u'errors'
:
...
@@ -176,6 +176,32 @@ EXPECTED_NON_EMPTY = {
...
@@ -176,6 +176,32 @@ EXPECTED_NON_EMPTY = {
u'time'
:
u'*'
,
u'time'
:
u'*'
,
u'timestamp'
:
u'*'
,
u'timestamp'
:
u'*'
,
u'classname'
:
u'SkippedTest'
u'classname'
:
u'SkippedTest'
},
{
u'name'
:
u'SkippedWithMessage'
,
u'status'
:
u'RUN'
,
u'result'
:
u'SKIPPED'
,
u'time'
:
u'*'
,
u'timestamp'
:
u'*'
,
u'classname'
:
u'SkippedTest'
},
{
u'name'
:
u'SkippedAfterFailure'
,
u'status'
:
u'RUN'
,
u'result'
:
u'COMPLETED'
,
u'time'
:
u'*'
,
u'timestamp'
:
u'*'
,
u'classname'
:
u'SkippedTest'
,
u'failures'
:
[{
u'failure'
:
u'gtest_xml_output_unittest_.cc:*
\n
'
u'Expected equality of these values:
\n
'
u' 1
\n
2'
+
STACK_TRACE_TEMPLATE
,
u'type'
:
u''
}]
}]
}]
},
{
},
{
u'name'
:
u'name'
:
...
...
googletest/test/gtest_xml_outfiles_test.py
View file @
07beabd6
...
@@ -42,7 +42,7 @@ GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_"
...
@@ -42,7 +42,7 @@ GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_"
EXPECTED_XML_1
=
"""<?xml version="1.0" encoding="UTF-8"?>
EXPECTED_XML_1
=
"""<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuite name="PropertyOne" tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*">
<testsuite name="PropertyOne" tests="1" failures="0"
skipped="0"
disabled="0" errors="0" time="*" timestamp="*">
<testcase name="TestSomeProperties" status="run" result="completed" time="*" timestamp="*" classname="PropertyOne">
<testcase name="TestSomeProperties" status="run" result="completed" time="*" timestamp="*" classname="PropertyOne">
<properties>
<properties>
<property name="SetUpProp" value="1"/>
<property name="SetUpProp" value="1"/>
...
@@ -56,7 +56,7 @@ EXPECTED_XML_1 = """<?xml version="1.0" encoding="UTF-8"?>
...
@@ -56,7 +56,7 @@ EXPECTED_XML_1 = """<?xml version="1.0" encoding="UTF-8"?>
EXPECTED_XML_2
=
"""<?xml version="1.0" encoding="UTF-8"?>
EXPECTED_XML_2
=
"""<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuite name="PropertyTwo" tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*">
<testsuite name="PropertyTwo" tests="1" failures="0"
skipped="0"
disabled="0" errors="0" time="*" timestamp="*">
<testcase name="TestSomeProperties" status="run" result="completed" time="*" timestamp="*" classname="PropertyTwo">
<testcase name="TestSomeProperties" status="run" result="completed" time="*" timestamp="*" classname="PropertyTwo">
<properties>
<properties>
<property name="SetUpProp" value="2"/>
<property name="SetUpProp" value="2"/>
...
...
googletest/test/gtest_xml_output_unittest.py
View file @
07beabd6
This diff is collapsed.
Click to expand it.
googletest/test/gtest_xml_output_unittest_.cc
View file @
07beabd6
...
@@ -74,6 +74,15 @@ TEST_F(SkippedTest, Skipped) {
...
@@ -74,6 +74,15 @@ TEST_F(SkippedTest, Skipped) {
GTEST_SKIP
();
GTEST_SKIP
();
}
}
TEST_F
(
SkippedTest
,
SkippedWithMessage
)
{
GTEST_SKIP
()
<<
"It is good practice to tell why you skip a test."
;
}
TEST_F
(
SkippedTest
,
SkippedAfterFailure
)
{
EXPECT_EQ
(
1
,
2
);
GTEST_SKIP
()
<<
"It is good practice to tell why you skip a test."
;
}
TEST
(
MixedResultTest
,
Succeeds
)
{
TEST
(
MixedResultTest
,
Succeeds
)
{
EXPECT_EQ
(
1
,
1
);
EXPECT_EQ
(
1
,
1
);
ASSERT_EQ
(
1
,
1
);
ASSERT_EQ
(
1
,
1
);
...
...
googletest/test/gtest_xml_test_utils.py
View file @
07beabd6
...
@@ -105,6 +105,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
...
@@ -105,6 +105,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
'testsuite'
:
'name'
,
'testsuite'
:
'name'
,
'testcase'
:
'name'
,
'testcase'
:
'name'
,
'failure'
:
'message'
,
'failure'
:
'message'
,
'skipped'
:
'message'
,
'property'
:
'name'
,
'property'
:
'name'
,
}
}
...
@@ -179,7 +180,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
...
@@ -179,7 +180,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
type_param
=
element
.
getAttributeNode
(
'type_param'
)
type_param
=
element
.
getAttributeNode
(
'type_param'
)
if
type_param
and
type_param
.
value
:
if
type_param
and
type_param
.
value
:
type_param
.
value
=
'*'
type_param
.
value
=
'*'
elif
element
.
tagName
==
'failure'
:
elif
element
.
tagName
==
'failure'
or
element
.
tagName
==
'skipped'
:
source_line_pat
=
r'^.*[/\\](.*:)\d+\n'
source_line_pat
=
r'^.*[/\\](.*:)\d+\n'
# Replaces the source line information with a normalized form.
# Replaces the source line information with a normalized form.
message
=
element
.
getAttributeNode
(
'message'
)
message
=
element
.
getAttributeNode
(
'message'
)
...
...
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