summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2013-04-25 17:58:52 +0000
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2013-04-25 17:58:52 +0000
commitc567ac6c5431d9d2867ace1da1418f4575215516 (patch)
tree974ef77e56b205a43cc7dbe8005d65391668e537 /test
parent03f2695f34fb7224b643828de1ce242a749dab42 (diff)
downloadgoogletest-c567ac6c5431d9d2867ace1da1418f4575215516.tar.gz
When --gtest_filter is specified, XML report now doesn't contain information about tests that are filtered out (issue 141).
git-svn-id: http://googletest.googlecode.com/svn/trunk@654 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'test')
-rw-r--r--test/gtest_output_test_golden_lin.txt5
-rwxr-xr-xtest/gtest_xml_output_unittest.py35
-rwxr-xr-xtest/gtest_xml_test_utils.py8
3 files changed, 34 insertions, 14 deletions
diff --git a/test/gtest_output_test_golden_lin.txt b/test/gtest_output_test_golden_lin.txt
index 0e26d63..960eedc 100644
--- a/test/gtest_output_test_golden_lin.txt
+++ b/test/gtest_output_test_golden_lin.txt
@@ -699,8 +699,6 @@ Expected: (3) >= (a[i]), actual: 3 vs 6
[ FAILED ] LoggingTest.InterleavingLoggingAndAssertions
4 FAILED TESTS
- YOU HAVE 1 DISABLED TEST
-
Note: Google Test filter = *DISABLED_*
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
@@ -720,6 +718,3 @@ Note: This is test shard 2 of 2.
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran.
[ PASSED ] 1 test.
-
- YOU HAVE 1 DISABLED TEST
-
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,
diff --git a/test/gtest_xml_test_utils.py b/test/gtest_xml_test_utils.py
index 35458f8..3d0c3b2 100755
--- a/test/gtest_xml_test_utils.py
+++ b/test/gtest_xml_test_utils.py
@@ -90,9 +90,11 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
actual_attr is not None,
'expected attribute %s not found in element %s' %
(expected_attr.name, actual_node.tagName))
- self.assertEquals(expected_attr.value, actual_attr.value,
- ' values of attribute %s in element %s differ' %
- (expected_attr.name, actual_node.tagName))
+ self.assertEquals(
+ expected_attr.value, actual_attr.value,
+ ' values of attribute %s in element %s differ: %s vs %s' %
+ (expected_attr.name, actual_node.tagName,
+ expected_attr.value, actual_attr.value))
expected_children = self._GetChildren(expected_node)
actual_children = self._GetChildren(actual_node)