diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 3384c024..74df5492 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3448,6 +3448,11 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
// to delimit this attribute from prior attributes.
static std::string TestPropertiesAsXmlAttributes(const TestResult& result);
+ // Streams an XML representation of the test properties of a TestResult
+ // object.
+ static void OutputXmlTestProperties(std::ostream* stream,
+ const TestResult& result);
+
// The output file.
const std::string output_file_;
@@ -3659,6 +3664,10 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
const TestResult& result = *test_info.result();
const std::string kTestcase = "testcase";
+ if (test_info.is_in_another_shard()) {
+ return;
+ }
+
*stream << " \n";
- else
+ } else {
+ if (failures == 0) {
+ *stream << ">\n";
+ }
+ OutputXmlTestProperties(stream, result);
*stream << " \n";
+ }
}
// Prints an XML representation of a TestCase object
@@ -3780,6 +3793,26 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
return attributes.GetString();
}
+void XmlUnitTestResultPrinter::OutputXmlTestProperties(
+ std::ostream* stream, const TestResult& result) {
+ const std::string kProperties = "properties";
+ const std::string kProperty = "property";
+
+ if (result.test_property_count() <= 0) {
+ return;
+ }
+
+ *stream << "<" << kProperties << ">\n";
+ for (int i = 0; i < result.test_property_count(); ++i) {
+ const TestProperty& property = result.GetTestProperty(i);
+ *stream << "<" << kProperty;
+ *stream << " name=\"" << EscapeXmlAttribute(property.key()) << "\"";
+ *stream << " value=\"" << EscapeXmlAttribute(property.value()) << "\"";
+ *stream << "/>\n";
+ }
+ *stream << "" << kProperties << ">\n";
+}
+
// End XmlUnitTestResultPrinter
diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py
index 24c6ee6b..c7d34134 100755
--- a/googletest/test/gtest_xml_outfiles_test.py
+++ b/googletest/test/gtest_xml_outfiles_test.py
@@ -43,7 +43,13 @@ GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_"
EXPECTED_XML_1 = """
-
+
+
+
+
+
+
+
"""
@@ -51,7 +57,13 @@ EXPECTED_XML_1 = """
EXPECTED_XML_2 = """
-
+
+
+
+
+
+
+
"""
diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py
index 325ca131..6ffb6e3f 100755
--- a/googletest/test/gtest_xml_output_unittest.py
+++ b/googletest/test/gtest_xml_output_unittest.py
@@ -104,15 +104,45 @@ Invalid characters in brackets []%(stack)s]]>
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -149,7 +179,11 @@ EXPECTED_SHARDED_TEST_XML = """
-
+
+
+
+
+
diff --git a/googletest/test/gtest_xml_test_utils.py b/googletest/test/gtest_xml_test_utils.py
index d303425c..1e035859 100755
--- a/googletest/test/gtest_xml_test_utils.py
+++ b/googletest/test/gtest_xml_test_utils.py
@@ -101,19 +101,22 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
self.AssertEquivalentNodes(child, actual_children[child_id])
identifying_attribute = {
- 'testsuites': 'name',
- 'testsuite': 'name',
- 'testcase': 'name',
- 'failure': 'message',
- }
+ 'testsuites': 'name',
+ 'testsuite': 'name',
+ 'testcase': 'name',
+ 'failure': 'message',
+ 'property': 'name',
+ }
def _GetChildren(self, element):
"""
Fetches all of the child nodes of element, a DOM Element object.
Returns them as the values of a dictionary keyed by the IDs of the
- children. For , and elements, the ID
- is the value of their "name" attribute; for elements, it is
- the value of the "message" attribute; CDATA sections and non-whitespace
+ children. For , , , and
+ elements, the ID is the value of their "name" attribute; for
+ elements, it is the value of the "message" attribute; for
+ elements, it is the value of their parent's "name" attribute plus the
+ literal string "properties"; CDATA sections and non-whitespace
text nodes are concatenated into a single CDATA section with ID
"detail". An exception is raised if any element other than the above
four is encountered, if two child elements with the same identifying
@@ -123,11 +126,17 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
children = {}
for child in element.childNodes:
if child.nodeType == Node.ELEMENT_NODE:
- self.assert_(child.tagName in self.identifying_attribute,
- 'Encountered unknown element <%s>' % child.tagName)
- childID = child.getAttribute(self.identifying_attribute[child.tagName])
- self.assert_(childID not in children)
- children[childID] = child
+ if child.tagName == 'properties':
+ self.assert_(child.parentNode is not None,
+ 'Encountered element without a parent')
+ child_id = child.parentNode.getAttribute('name') + '-properties'
+ else:
+ self.assert_(child.tagName in self.identifying_attribute,
+ 'Encountered unknown element <%s>' % child.tagName)
+ child_id = child.getAttribute(
+ self.identifying_attribute[child.tagName])
+ self.assert_(child_id not in children)
+ children[child_id] = child
elif child.nodeType in [Node.TEXT_NODE, Node.CDATA_SECTION_NODE]:
if 'detail' not in children:
if (child.nodeType == Node.CDATA_SECTION_NODE or