diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-03-24 20:39:44 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-03-24 20:39:44 +0000 |
commit | 2c0fc6d415343b732a4ae39cce1458be1170b9f6 (patch) | |
tree | c5ab10847116c91a6e4bc12a2945b3d77f70fd21 /test | |
parent | 1f8a50e429735ded6b27bfdfb96d0e0aa4d8627b (diff) | |
download | googletest-2c0fc6d415343b732a4ae39cce1458be1170b9f6.tar.gz googletest-2c0fc6d415343b732a4ae39cce1458be1170b9f6.tar.bz2 googletest-2c0fc6d415343b732a4ae39cce1458be1170b9f6.zip |
Cleans up death test implementation (by Vlad Losev); changes the XML format to be closer to junitreport (by Zhanyong Wan).
Diffstat (limited to 'test')
-rw-r--r-- | test/gtest-death-test_test.cc | 17 | ||||
-rwxr-xr-x | test/gtest_xml_outfiles_test.py | 8 | ||||
-rwxr-xr-x | test/gtest_xml_output_unittest.py | 8 | ||||
-rwxr-xr-x | test/gtest_xml_test_utils.py | 25 |
4 files changed, 26 insertions, 32 deletions
diff --git a/test/gtest-death-test_test.cc b/test/gtest-death-test_test.cc index 2c283b63..a6d7b18d 100644 --- a/test/gtest-death-test_test.cc +++ b/test/gtest-death-test_test.cc @@ -65,7 +65,7 @@ using testing::Message; using testing::internal::DeathTest; using testing::internal::DeathTestFactory; using testing::internal::FilePath; -using testing::internal::GetLastSystemErrorMessage; +using testing::internal::GetLastErrnoDescription; using testing::internal::ParseNaturalNumber; using testing::internal::String; @@ -990,20 +990,13 @@ TEST(StreamingAssertionsDeathTest, DeathTest) { }, "expected failure"); } -// Tests that GetLastSystemErrorMessage returns an empty string when the +// Tests that GetLastErrnoDescription returns an empty string when the // last error is 0 and non-empty string when it is non-zero. -TEST(GetLastSystemErrorMessageTest, GetLastSystemErrorMessageWorks) { -#if GTEST_OS_WINDOWS - ::SetLastError(ERROR_FILE_NOT_FOUND); - EXPECT_STRNE("", GetLastSystemErrorMessage().c_str()); - ::SetLastError(0); - EXPECT_STREQ("", GetLastSystemErrorMessage().c_str()); -#else +TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) { errno = ENOENT; - EXPECT_STRNE("", GetLastSystemErrorMessage().c_str()); + EXPECT_STRNE("", GetLastErrnoDescription().c_str()); errno = 0; - EXPECT_STREQ("", GetLastSystemErrorMessage().c_str()); -#endif + EXPECT_STREQ("", GetLastErrnoDescription().c_str()); } #if GTEST_OS_WINDOWS diff --git a/test/gtest_xml_outfiles_test.py b/test/gtest_xml_outfiles_test.py index 4ebc15ef..3e91f6de 100755 --- a/test/gtest_xml_outfiles_test.py +++ b/test/gtest_xml_outfiles_test.py @@ -48,19 +48,19 @@ GTEST_OUTPUT_1_TEST = "gtest_xml_outfile1_test_" GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_" EXPECTED_XML_1 = """<?xml version="1.0" encoding="UTF-8"?> -<testsuite tests="1" failures="0" disabled="0" errors="0" time="*" name="AllTests"> +<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" name="AllTests"> <testsuite name="PropertyOne" tests="1" failures="0" disabled="0" errors="0" time="*"> <testcase name="TestSomeProperties" status="run" time="*" classname="PropertyOne" SetUpProp="1" TestSomeProperty="1" TearDownProp="1" /> </testsuite> -</testsuite> +</testsuites> """ EXPECTED_XML_2 = """<?xml version="1.0" encoding="UTF-8"?> -<testsuite tests="1" failures="0" disabled="0" errors="0" time="*" name="AllTests"> +<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" name="AllTests"> <testsuite name="PropertyTwo" tests="1" failures="0" disabled="0" errors="0" time="*"> <testcase name="TestSomeProperties" status="run" time="*" classname="PropertyTwo" SetUpProp="2" TestSomeProperty="2" TearDownProp="2" /> </testsuite> -</testsuite> +</testsuites> """ diff --git a/test/gtest_xml_output_unittest.py b/test/gtest_xml_output_unittest.py index 5e0b220b..4587c41b 100755 --- a/test/gtest_xml_output_unittest.py +++ b/test/gtest_xml_output_unittest.py @@ -48,7 +48,7 @@ GTEST_OUTPUT_FLAG = "--gtest_output" GTEST_DEFAULT_OUTPUT_FILE = "test_detail.xml" EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?> -<testsuite tests="13" failures="2" disabled="2" errors="0" time="*" name="AllTests"> +<testsuites tests="13" failures="2" disabled="2" errors="0" time="*" name="AllTests"> <testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*"> <testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/> </testsuite> @@ -85,12 +85,12 @@ Expected: 2]]></failure> <testcase name="ExternalUtilityThatCallsRecordIntValuedProperty" status="run" time="*" classname="NoFixtureTest" key_for_utility_int="1"/> <testcase name="ExternalUtilityThatCallsRecordStringValuedProperty" status="run" time="*" classname="NoFixtureTest" key_for_utility_string="1"/> </testsuite> -</testsuite>""" +</testsuites>""" EXPECTED_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?> -<testsuite tests="0" failures="0" disabled="0" errors="0" time="*" name="AllTests"> -</testsuite>""" +<testsuites tests="0" failures="0" disabled="0" errors="0" time="*" name="AllTests"> +</testsuites>""" class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): diff --git a/test/gtest_xml_test_utils.py b/test/gtest_xml_test_utils.py index 5694dff9..00a56cbf 100755 --- a/test/gtest_xml_test_utils.py +++ b/test/gtest_xml_test_utils.py @@ -92,6 +92,7 @@ class GTestXMLTestCase(unittest.TestCase): self.AssertEquivalentNodes(child, actual_children[child_id]) identifying_attribute = { + "testsuites": "name", "testsuite": "name", "testcase": "name", "failure": "message", @@ -101,14 +102,14 @@ class GTestXMLTestCase(unittest.TestCase): """ 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 <testsuite> and <testcase> elements, the ID is the - value of their "name" attribute; for <failure> elements, it is the - value of the "message" attribute; for CDATA section node, it is - "detail". An exception is raised if any element other than the - above four is encountered, if two child elements with the same - identifying attributes are encountered, or if any other type of - node is encountered, other than Text nodes containing only - whitespace. + children. For <testsuites>, <testsuite> and <testcase> elements, + the ID is the value of their "name" attribute; for <failure> + elements, it is the value of the "message" attribute; for CDATA + section node, it is "detail". An exception is raised if any + element other than the above four is encountered, if two child + elements with the same identifying attributes are encountered, or + if any other type of node is encountered, other than Text nodes + containing only whitespace. """ children = {} @@ -133,16 +134,16 @@ class GTestXMLTestCase(unittest.TestCase): Normalizes Google Test's XML output to eliminate references to transient information that may change from run to run. - * The "time" attribute of <testsuite> and <testcase> elements is - replaced with a single asterisk, if it contains only digit - characters. + * The "time" attribute of <testsuites>, <testsuite> and <testcase> + elements is replaced with a single asterisk, if it contains + only digit characters. * The line number reported in the first line of the "message" attribute of <failure> elements is replaced with a single asterisk. * The directory names in file paths are removed. * The stack traces are removed. """ - if element.tagName in ("testsuite", "testcase"): + if element.tagName in ("testsuites", "testsuite", "testcase"): time = element.getAttributeNode("time") time.value = re.sub(r"^\d+(\.\d+)?$", "*", time.value) elif element.tagName == "failure": |