summaryrefslogtreecommitdiffstats
path: root/test/gtest_xml_output_unittest.py
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2013-04-25 17:58:52 (GMT)
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2013-04-25 17:58:52 (GMT)
commitc506784b08473f3ba8f37d588fd08d8d3f948245 (patch)
tree974ef77e56b205a43cc7dbe8005d65391668e537 /test/gtest_xml_output_unittest.py
parentc84afbeaf1003ae2d4a0f6d36bbb8938bc73bbc7 (diff)
downloadgoogletest-c506784b08473f3ba8f37d588fd08d8d3f948245.zip
googletest-c506784b08473f3ba8f37d588fd08d8d3f948245.tar.gz
googletest-c506784b08473f3ba8f37d588fd08d8d3f948245.tar.bz2
When --gtest_filter is specified, XML report now doesn't contain information about tests that are filtered out (issue 141).
Diffstat (limited to 'test/gtest_xml_output_unittest.py')
-rwxr-xr-xtest/gtest_xml_output_unittest.py35
1 files changed, 29 insertions, 6 deletions
diff --git a/test/gtest_xml_output_unittest.py b/test/gtest_xml_output_unittest.py
index 3d794e6..f605d4e 100755
--- a/test/gtest_xml_output_unittest.py
+++ b/test/gtest_xml_output_unittest.py
@@ -44,6 +44,7 @@ import gtest_test_utils
import gtest_xml_test_utils
+GTEST_FILTER_FLAG = '--gtest_filter'
GTEST_LIST_TESTS_FLAG = '--gtest_list_tests'
GTEST_OUTPUT_FLAG = "--gtest_output"
GTEST_DEFAULT_OUTPUT_FILE = "test_detail.xml"
@@ -128,9 +129,18 @@ Invalid characters in brackets []%(stack)s]]></failure>
</testsuite>
</testsuites>""" % {'stack': STACK_TRACE_TEMPLATE}
+EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
+<testsuites tests="1" failures="0" disabled="0" errors="0" time="*"
+ timestamp="*" name="AllTests" ad_hoc_property="42">
+ <testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0"
+ errors="0" time="*">
+ <testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
+ </testsuite>
+</testsuites>"""
EXPECTED_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
-<testsuites tests="0" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
+<testsuites tests="0" failures="0" disabled="0" errors="0" time="*"
+ timestamp="*" name="AllTests">
</testsuites>"""
GTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME)
@@ -169,7 +179,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
Runs a test program that generates an empty XML output, and checks if
the timestamp attribute in the testsuites tag is valid.
"""
- actual = self._GetXmlOutput('gtest_no_test_unittest', 0)
+ actual = self._GetXmlOutput('gtest_no_test_unittest', [], 0)
date_time_str = actual.documentElement.getAttributeNode('timestamp').value
# datetime.strptime() is only available in Python 2.5+ so we have to
# parse the expected datetime manually.
@@ -239,7 +249,17 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
self.assert_(not os.path.isfile(xml_path))
- def _GetXmlOutput(self, gtest_prog_name, expected_exit_code):
+ def testFilteredTestXmlOutput(self):
+ """Verifies XML output when a filter is applied.
+
+ Runs a test program that executes only some tests and verifies that
+ non-selected tests do not show up in the XML output.
+ """
+
+ self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0,
+ extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG])
+
+ def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code):
"""
Returns the xml output generated by running the program gtest_prog_name.
Furthermore, the program's exit code must be expected_exit_code.
@@ -248,7 +268,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
gtest_prog_name + 'out.xml')
gtest_prog_path = gtest_test_utils.GetTestExecutablePath(gtest_prog_name)
- command = [gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)]
+ command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] +
+ extra_args)
p = gtest_test_utils.Subprocess(command)
if p.terminated_by_signal:
self.assert_(False,
@@ -262,7 +283,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
actual = minidom.parse(xml_path)
return actual
- def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code):
+ def _TestXmlOutput(self, gtest_prog_name, expected_xml,
+ expected_exit_code, extra_args=None):
"""
Asserts that the XML document generated by running the program
gtest_prog_name matches expected_xml, a string containing another
@@ -270,7 +292,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
expected_exit_code.
"""
- actual = self._GetXmlOutput(gtest_prog_name, expected_exit_code)
+ actual = self._GetXmlOutput(gtest_prog_name, extra_args or [],
+ expected_exit_code)
expected = minidom.parseString(expected_xml)
self.NormalizeXml(actual.documentElement)
self.AssertEquivalentNodes(expected.documentElement,