aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorjgm <jgm@google.com>2012-01-17 15:11:32 +0000
committerjgm <jgm@google.com>2012-01-17 15:11:32 +0000
commit4d6f296e8e5d3f839ef4868390bbec27cb12e068 (patch)
tree1d5652c238bd324c2c3181c451f74b1fed8405da /test
parent69a071bc0d1c87b9b8271e8d7545ade7086be6bb (diff)
downloadgoogletest-4d6f296e8e5d3f839ef4868390bbec27cb12e068.tar.gz
googletest-4d6f296e8e5d3f839ef4868390bbec27cb12e068.tar.bz2
googletest-4d6f296e8e5d3f839ef4868390bbec27cb12e068.zip
Adds file and line information to the "message", which is used as the summary
of a failure.
Diffstat (limited to 'test')
-rwxr-xr-xtest/gtest_xml_output_unittest.py10
-rwxr-xr-xtest/gtest_xml_test_utils.py13
2 files changed, 14 insertions, 9 deletions
diff --git a/test/gtest_xml_output_unittest.py b/test/gtest_xml_output_unittest.py
index 83903002..1bcd4187 100755
--- a/test/gtest_xml_output_unittest.py
+++ b/test/gtest_xml_output_unittest.py
@@ -63,7 +63,7 @@ EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
</testsuite>
<testsuite name="FailedTest" tests="1" failures="1" disabled="0" errors="0" time="*">
<testcase name="Fails" status="run" time="*" classname="FailedTest">
- <failure message="Value of: 2&#x0A;Expected: 1" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Value of: 2&#x0A;Expected: 1" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Value of: 2
Expected: 1%(stack)s]]></failure>
</testcase>
@@ -71,10 +71,10 @@ Expected: 1%(stack)s]]></failure>
<testsuite name="MixedResultTest" tests="3" failures="1" disabled="1" errors="0" time="*">
<testcase name="Succeeds" status="run" time="*" classname="MixedResultTest"/>
<testcase name="Fails" status="run" time="*" classname="MixedResultTest">
- <failure message="Value of: 2&#x0A;Expected: 1" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Value of: 2&#x0A;Expected: 1" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Value of: 2
Expected: 1%(stack)s]]></failure>
- <failure message="Value of: 3&#x0A;Expected: 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Value of: 3&#x0A;Expected: 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Value of: 3
Expected: 2%(stack)s]]></failure>
</testcase>
@@ -82,14 +82,14 @@ Expected: 2%(stack)s]]></failure>
</testsuite>
<testsuite name="XmlQuotingTest" tests="1" failures="1" disabled="0" errors="0" time="*">
<testcase name="OutputsCData" status="run" time="*" classname="XmlQuotingTest">
- <failure message="Failed&#x0A;XML output: &lt;?xml encoding=&quot;utf-8&quot;&gt;&lt;top&gt;&lt;![CDATA[cdata text]]&gt;&lt;/top&gt;" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;XML output: &lt;?xml encoding=&quot;utf-8&quot;&gt;&lt;top&gt;&lt;![CDATA[cdata text]]&gt;&lt;/top&gt;" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Failed
XML output: <?xml encoding="utf-8"><top><![CDATA[cdata text]]>]]&gt;<![CDATA[</top>%(stack)s]]></failure>
</testcase>
</testsuite>
<testsuite name="InvalidCharactersTest" tests="1" failures="1" disabled="0" errors="0" time="*">
<testcase name="InvalidCharactersInMessage" status="run" time="*" classname="InvalidCharactersTest">
- <failure message="Failed&#x0A;Invalid characters in brackets []" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
+ <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;Invalid characters in brackets []" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Failed
Invalid characters in brackets []%(stack)s]]></failure>
</testcase>
diff --git a/test/gtest_xml_test_utils.py b/test/gtest_xml_test_utils.py
index f94d634b..0e5a1089 100755
--- a/test/gtest_xml_test_utils.py
+++ b/test/gtest_xml_test_utils.py
@@ -156,8 +156,9 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
* 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
by the compiler and is platform dependent.
- * The line number reported in the first line of the "message"
- attribute of <failure> elements is replaced with a single asterisk.
+ * The line info reported in the first line of the "message"
+ 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 stack traces are removed.
"""
@@ -173,10 +174,14 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
if type_param and type_param.value:
type_param.value = '*'
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:
if child.nodeType == Node.CDATA_SECTION_NODE:
- # Removes the source line number.
- cdata = re.sub(r'^.*[/\\](.*:)\d+\n', '\\1*\n', child.nodeValue)
+ # Replaces the source line information with a normalized form.
+ cdata = re.sub(source_line_pat, '\\1*\n', child.nodeValue)
# Removes the actual stack trace.
child.nodeValue = re.sub(r'\nStack trace:\n(.|\n)*',
'', cdata)