From 2c0fc6d415343b732a4ae39cce1458be1170b9f6 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Tue, 24 Mar 2009 20:39:44 +0000 Subject: Cleans up death test implementation (by Vlad Losev); changes the XML format to be closer to junitreport (by Zhanyong Wan). --- test/gtest-death-test_test.cc | 17 +++++------------ test/gtest_xml_outfiles_test.py | 8 ++++---- test/gtest_xml_output_unittest.py | 8 ++++---- test/gtest_xml_test_utils.py | 25 +++++++++++++------------ 4 files changed, 26 insertions(+), 32 deletions(-) (limited to 'test') 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 = """ - + - + """ EXPECTED_XML_2 = """ - + - + """ 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 = """ - + @@ -85,12 +85,12 @@ Expected: 2]]> -""" +""" EXPECTED_EMPTY_XML = """ - -""" + +""" 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 and elements, the ID is the - value of their "name" attribute; for 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 , and elements, + the ID is the value of their "name" attribute; for + 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 and elements is - replaced with a single asterisk, if it contains only digit - characters. + * The "time" attribute of , and + 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 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": -- cgit v1.2.3