2011-01-06 Eric Seidel <eric@webkit.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Jan 2011 21:30:15 +0000 (21:30 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Jan 2011 21:30:15 +0000 (21:30 +0000)
        Reviewed by Mihai Parparita.

        commit-queue mentions "Text diff mismatch" 4 times instead of once per failure
        https://bugs.webkit.org/show_bug.cgi?id=52002

        See an example of this here:
        https://bugs.webkit.org/show_bug.cgi?id=51314#c2

        It's due to the fact that we pass around TestFailure() instance
        objects and yet expect them to all compare to be the same.

        This is bad.  We should either have shared instances of these values
        or we should just pass around the class names.  There are already hacks
        in place to make TestFailure objects pass equality tests, I just added
        a __hash__ implementation so they can be used in sets as expected.

        * Scripts/webkitpy/common/net/layouttestresults_unittest.py:
        * Scripts/webkitpy/layout_tests/layout_package/test_failures.py:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75191 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/net/layouttestresults_unittest.py
Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py
Tools/Scripts/webkitpy/layout_tests/layout_package/test_failures_unittest.py

index bced14395a419529bbfc2e757be574839b0b9899..7577432633facad473c7bb630b3389a73613692a 100644 (file)
@@ -1,3 +1,24 @@
+2011-01-06  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Mihai Parparita.
+
+        commit-queue mentions "Text diff mismatch" 4 times instead of once per failure
+        https://bugs.webkit.org/show_bug.cgi?id=52002
+
+        See an example of this here:
+        https://bugs.webkit.org/show_bug.cgi?id=51314#c2
+
+        It's due to the fact that we pass around TestFailure() instance
+        objects and yet expect them to all compare to be the same.
+
+        This is bad.  We should either have shared instances of these values
+        or we should just pass around the class names.  There are already hacks
+        in place to make TestFailure objects pass equality tests, I just added
+        a __hash__ implementation so they can be used in sets as expected.
+
+        * Scripts/webkitpy/common/net/layouttestresults_unittest.py:
+        * Scripts/webkitpy/layout_tests/layout_package/test_failures.py:
+
 2011-01-06  Evan Martin  <evan@chromium.org>
 
         Reviewed by Tony Chang.
index d274dbf9e3ec1e8f7abbc52eec8514396ec5875f..01b91b8350f9323710a7facae44d3d07b0512529 100644 (file)
@@ -76,7 +76,7 @@ class LayoutTestResultsTest(unittest.TestCase):
         self.assertEqual(len(results.failing_tests()), 0)
 
     def test_failures_from_fail_row(self):
-        row = BeautifulSoup("<tr><td><a>test.hml</a><a>25%</a></td></tr>")
+        row = BeautifulSoup("<tr><td><a>test.hml</a></td><td><a>expected image</a></td><td><a>25%</a></td></tr>")
         test_name = unicode(row.find("a").string)
         # Even if the caller has already found the test name, findAll inside _failures_from_fail_row will see it again.
         failures = OutputCapture().assert_outputs(self, LayoutTestResults._failures_from_fail_row, [row])
index d537d50fa94726411f8e7555ee7b6b99d53fe28b..5dd0114e633707ca491c857bb2ffea7f2d2d0beb 100644 (file)
@@ -91,6 +91,9 @@ class TestFailure(object):
     def __ne__(self, other):
         return self.__class__.__name__ != other.__class__.__name__
 
+    def __hash__(self):
+        return hash(self.__class__.__name__)
+
     def dumps(self):
         """Returns the string/JSON representation of a TestFailure."""
         return cPickle.dumps(self)
@@ -128,9 +131,6 @@ class FailureWithType(TestFailure):
     use the standard OutputLinks.
     """
 
-    def __init__(self):
-        TestFailure.__init__(self)
-
     # Filename suffixes used by ResultHtmlOutput.
     OUT_FILENAMES = ()
 
index 3e3528dc7807494a0a7eabe413234a6e673ce330..b2698d175dd204d145bd1cc329fbfbdc5cc8237c 100644 (file)
@@ -80,5 +80,15 @@ class Test(unittest.TestCase):
         for c in ALL_FAILURE_CLASSES:
             self.assert_loads(c)
 
+    def test_equals(self):
+        self.assertEqual(FailureCrash(), FailureCrash())
+        self.assertNotEqual(FailureCrash(), FailureTimeout())
+        crash_set = set([FailureCrash(), FailureCrash()])
+        self.assertEqual(len(crash_set), 1)
+        # The hash happens to be the name of the class, but sets still work:
+        crash_set = set([FailureCrash(), "FailureCrash"])
+        self.assertEqual(len(crash_set), 2)
+
+
 if __name__ == '__main__':
     unittest.main()