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
4d6f296e
Commit
4d6f296e
authored
Jan 17, 2012
by
jgm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds file and line information to the "message", which is used as the summary
of a failure.
parent
69a071bc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
17 deletions
+23
-17
gtest-internal-inl.h
src/gtest-internal-inl.h
+1
-1
gtest.cc
src/gtest.cc
+8
-7
gtest_xml_output_unittest.py
test/gtest_xml_output_unittest.py
+5
-5
gtest_xml_test_utils.py
test/gtest_xml_test_utils.py
+9
-4
No files found.
src/gtest-internal-inl.h
View file @
4d6f296e
...
@@ -620,7 +620,7 @@ class GTEST_API_ UnitTestImpl {
...
@@ -620,7 +620,7 @@ class GTEST_API_ UnitTestImpl {
// For example, if Foo() calls Bar(), which in turn calls
// For example, if Foo() calls Bar(), which in turn calls
// CurrentOsStackTraceExceptTop(1), Foo() will be included in the
// CurrentOsStackTraceExceptTop(1), Foo() will be included in the
// trace but Bar() and CurrentOsStackTraceExceptTop() won't.
// trace but Bar() and CurrentOsStackTraceExceptTop() won't.
String
CurrentOsStackTraceExceptTop
(
int
skip_count
);
String
CurrentOsStackTraceExceptTop
(
int
skip_count
)
GTEST_NO_INLINE_
;
// Finds and returns a TestCase with the given name. If one doesn't
// Finds and returns a TestCase with the given name. If one doesn't
// exist, creates one and returns it.
// exist, creates one and returns it.
...
...
src/gtest.cc
View file @
4d6f296e
...
@@ -3271,16 +3271,17 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
...
@@ -3271,16 +3271,17 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
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
)
{
*
stream
<<
">
\n
"
;
*
stream
<<
">
\n
"
;
*
stream
<<
" <failure message=
\"
"
}
<<
EscapeXmlAttribute
(
part
.
summary
()).
c_str
()
<<
"
\"
type=
\"\"
>"
;
const
string
location
=
internal
::
FormatCompilerIndependentFileLocation
(
const
string
location
=
internal
::
FormatCompilerIndependentFileLocation
(
part
.
file_name
(),
part
.
line_number
());
part
.
file_name
(),
part
.
line_number
());
const
string
message
=
location
+
"
\n
"
+
part
.
message
();
const
string
summary
=
location
+
"
\n
"
+
part
.
summary
();
OutputXmlCDataSection
(
stream
,
*
stream
<<
" <failure message=
\"
"
RemoveInvalidXmlCharacters
(
message
).
c_str
());
<<
EscapeXmlAttribute
(
summary
.
c_str
())
<<
"
\"
type=
\"\"
>"
;
const
string
detail
=
location
+
"
\n
"
+
part
.
message
();
OutputXmlCDataSection
(
stream
,
RemoveInvalidXmlCharacters
(
detail
).
c_str
());
*
stream
<<
"</failure>
\n
"
;
*
stream
<<
"</failure>
\n
"
;
}
}
}
}
...
...
test/gtest_xml_output_unittest.py
View file @
4d6f296e
...
@@ -63,7 +63,7 @@ EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
...
@@ -63,7 +63,7 @@ EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
</testsuite>
</testsuite>
<testsuite name="FailedTest" tests="1" failures="1" disabled="0" errors="0" time="*">
<testsuite name="FailedTest" tests="1" failures="1" disabled="0" errors="0" time="*">
<testcase name="Fails" status="run" time="*" classname="FailedTest">
<testcase name="Fails" status="run" time="*" classname="FailedTest">
<failure message="Value of: 2
Expected: 1" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
<failure message="
gtest_xml_output_unittest_.cc:*

Value of: 2
Expected: 1" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Value of: 2
Value of: 2
Expected: 1
%(stack)
s]]></failure>
Expected: 1
%(stack)
s]]></failure>
</testcase>
</testcase>
...
@@ -71,10 +71,10 @@ Expected: 1%(stack)s]]></failure>
...
@@ -71,10 +71,10 @@ Expected: 1%(stack)s]]></failure>
<testsuite name="MixedResultTest" tests="3" failures="1" disabled="1" errors="0" time="*">
<testsuite name="MixedResultTest" tests="3" failures="1" disabled="1" errors="0" time="*">
<testcase name="Succeeds" status="run" time="*" classname="MixedResultTest"/>
<testcase name="Succeeds" status="run" time="*" classname="MixedResultTest"/>
<testcase name="Fails" status="run" time="*" classname="MixedResultTest">
<testcase name="Fails" status="run" time="*" classname="MixedResultTest">
<failure message="Value of: 2
Expected: 1" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
<failure message="
gtest_xml_output_unittest_.cc:*

Value of: 2
Expected: 1" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Value of: 2
Value of: 2
Expected: 1
%(stack)
s]]></failure>
Expected: 1
%(stack)
s]]></failure>
<failure message="Value of: 3
Expected: 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
<failure message="
gtest_xml_output_unittest_.cc:*

Value of: 3
Expected: 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Value of: 3
Value of: 3
Expected: 2
%(stack)
s]]></failure>
Expected: 2
%(stack)
s]]></failure>
</testcase>
</testcase>
...
@@ -82,14 +82,14 @@ Expected: 2%(stack)s]]></failure>
...
@@ -82,14 +82,14 @@ Expected: 2%(stack)s]]></failure>
</testsuite>
</testsuite>
<testsuite name="XmlQuotingTest" tests="1" failures="1" disabled="0" errors="0" time="*">
<testsuite name="XmlQuotingTest" tests="1" failures="1" disabled="0" errors="0" time="*">
<testcase name="OutputsCData" status="run" time="*" classname="XmlQuotingTest">
<testcase name="OutputsCData" status="run" time="*" classname="XmlQuotingTest">
<failure message="Failed
XML output: <?xml encoding="utf-8"><top><![CDATA[cdata text]]></top>" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
<failure message="
gtest_xml_output_unittest_.cc:*

Failed
XML output: <?xml encoding="utf-8"><top><![CDATA[cdata text]]></top>" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Failed
Failed
XML output: <?xml encoding="utf-8"><top><![CDATA[cdata text]]>]]><![CDATA[</top>
%(stack)
s]]></failure>
XML output: <?xml encoding="utf-8"><top><![CDATA[cdata text]]>]]><![CDATA[</top>
%(stack)
s]]></failure>
</testcase>
</testcase>
</testsuite>
</testsuite>
<testsuite name="InvalidCharactersTest" tests="1" failures="1" disabled="0" errors="0" time="*">
<testsuite name="InvalidCharactersTest" tests="1" failures="1" disabled="0" errors="0" time="*">
<testcase name="InvalidCharactersInMessage" status="run" time="*" classname="InvalidCharactersTest">
<testcase name="InvalidCharactersInMessage" status="run" time="*" classname="InvalidCharactersTest">
<failure message="Failed
Invalid characters in brackets []" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
<failure message="
gtest_xml_output_unittest_.cc:*

Failed
Invalid characters in brackets []" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Failed
Failed
Invalid characters in brackets []
%(stack)
s]]></failure>
Invalid characters in brackets []
%(stack)
s]]></failure>
</testcase>
</testcase>
...
...
test/gtest_xml_test_utils.py
View file @
4d6f296e
...
@@ -156,8 +156,9 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
...
@@ -156,8 +156,9 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
* The "type_param" attribute of <testcase> elements is replaced with a
* The "type_param" attribute of <testcase> elements is replaced with a
single asterisk (if it sn non-empty) as it is the type name returned
single asterisk (if it sn non-empty) as it is the type name returned
by the compiler and is platform dependent.
by the compiler and is platform dependent.
* The line number reported in the first line of the "message"
* The line info reported in the first line of the "message"
attribute of <failure> elements is replaced with a single asterisk.
attribute and CDATA section of <failure> elements is replaced with the
file's basename and a single asterisk for the line number.
* The directory names in file paths are removed.
* The directory names in file paths are removed.
* The stack traces are removed.
* The stack traces are removed.
"""
"""
...
@@ -173,10 +174,14 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
...
@@ -173,10 +174,14 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
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'
:
source_line_pat
=
r'^.*[/\\](.*:)\d+\n'
# Replaces the source line information with a normalized form.
message
=
element
.
getAttributeNode
(
'message'
)
message
.
value
=
re
.
sub
(
source_line_pat
,
'
\\
1*
\n
'
,
message
.
value
)
for
child
in
element
.
childNodes
:
for
child
in
element
.
childNodes
:
if
child
.
nodeType
==
Node
.
CDATA_SECTION_NODE
:
if
child
.
nodeType
==
Node
.
CDATA_SECTION_NODE
:
# Re
moves the source line number
.
# Re
places the source line information with a normalized form
.
cdata
=
re
.
sub
(
r'^.*[/\\](.*:)\d+\n'
,
'
\\
1*
\n
'
,
child
.
nodeValue
)
cdata
=
re
.
sub
(
source_line_pat
,
'
\\
1*
\n
'
,
child
.
nodeValue
)
# Removes the actual stack trace.
# Removes the actual stack trace.
child
.
nodeValue
=
re
.
sub
(
r'\nStack trace:\n(.|\n)*'
,
child
.
nodeValue
=
re
.
sub
(
r'\nStack trace:\n(.|\n)*'
,
''
,
cdata
)
''
,
cdata
)
...
...
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