Title: [92087] trunk/Tools
Revision
92087
Author
[email protected]
Date
2011-07-31 13:40:55 -0700 (Sun, 31 Jul 2011)

Log Message

Use set comparison to find duplicate or overlapping specifiers in test expectations.
https://bugs.webkit.org/show_bug.cgi?id=65430

Reviewed by Adam Barth.

* Scripts/webkitpy/layout_tests/models/test_expectations.py: Changed to use set comparisons, because length
    of a set is wrong.
* Scripts/webkitpy/style/checkers/test_expectations_unittest.py: Added some unit tests to actually catch
    regressions.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (92086 => 92087)


--- trunk/Tools/ChangeLog	2011-07-31 20:32:58 UTC (rev 92086)
+++ trunk/Tools/ChangeLog	2011-07-31 20:40:55 UTC (rev 92087)
@@ -1,3 +1,15 @@
+2011-07-31  Dimitri Glazkov  <[email protected]>
+
+        Use set comparison to find duplicate or overlapping specifiers in test expectations.
+        https://bugs.webkit.org/show_bug.cgi?id=65430
+
+        Reviewed by Adam Barth.
+
+        * Scripts/webkitpy/layout_tests/models/test_expectations.py: Changed to use set comparisons, because length
+            of a set is wrong.
+        * Scripts/webkitpy/style/checkers/test_expectations_unittest.py: Added some unit tests to actually catch
+            regressions.
+
 2011-07-31  Xan Lopez  <[email protected]>
 
         Group dependencies CFLAGS together.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py (92086 => 92087)


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2011-07-31 20:32:58 UTC (rev 92086)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2011-07-31 20:40:55 UTC (rev 92087)
@@ -527,21 +527,27 @@
         # To use the "more modifiers wins" policy, change the errors for overrides
         # to be warnings and return False".
 
-        prev_specificity = len(prev_expectation_line.matching_configurations)
-        specificity = len(prev_expectation_line.matching_configurations)
-        if prev_specificity == specificity:
+        if prev_expectation_line.matching_configurations == expectation_line.matching_configurations:
             expectation_line.errors.append('Duplicate or ambiguous %s.' % expectation_source)
             return True
 
-        if prev_specificity < specificity:
+        if prev_expectation_line.matching_configurations >= expectation_line.matching_configurations:
             expectation_line.errors.append('More specific entry on line %d overrides line %d' % (expectation_line.line_number, prev_expectation_line.line_number))
             # FIXME: return False if we want more specific to win.
             return True
 
-        expectation_line.errors.append('More specific entry on line %d overrides line %d' % (prev_expectation_line.line_number, expectation_line.line_number))
-        return True
+        if prev_expectation_line.matching_configurations <= expectation_line.matching_configurations:
+            expectation_line.errors.append('More specific entry on line %d overrides line %d' % (prev_expectation_line.line_number, expectation_line.line_number))
+            return True
 
+        if prev_expectation_line.matching_configurations & expectation_line.matching_configurations:
+            expectation_line.errors.append('Entries on line %d and line %d match overlapping sets of configurations' % (prev_expectation_line.line_number, expectation_line.line_number))
+            return True
 
+        # Configuration sets are disjoint, then.
+        return False
+
+
 class TestExpectations:
     """Test expectations consist of lines with specifications of what
     to expect from layout test cases. The test cases can be directories

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations_unittest.py (92086 => 92087)


--- trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations_unittest.py	2011-07-31 20:32:58 UTC (rev 92086)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations_unittest.py	2011-07-31 20:40:55 UTC (rev 92087)
@@ -151,6 +151,32 @@
              "BUGWK1 : passes/text.html = TIMEOUT"],
             "Duplicate or ambiguous expectation. %s  [test/expectations] [5]" % self._test_file)
 
+        self.assert_lines_lint(
+            ["BUGWK1 LEOPARD : passes/text.html = PASS",
+             "BUGWK1 MAC : passes/text.html = TIMEOUT"],
+            "More specific entry on line 1 overrides line 2 passes/text.html  [test/expectations] [5]")
+
+        self.assert_lines_lint(
+            ["BUGWK1 LEOPARD : passes/text.html = PASS",
+             "BUGWK1 LEOPARD RELEASE : passes/text.html = TIMEOUT"],
+            "More specific entry on line 2 overrides line 1 passes/text.html  [test/expectations] [5]")
+
+        self.assert_lines_lint(
+            ["BUGWK1 RELEASE : passes/text.html = PASS",
+             "BUGWK1 CPU : passes/text.html = TIMEOUT"],
+            "Entries on line 1 and line 2 match overlapping sets of configurations passes/text.html  [test/expectations] [5]")
+
+        self.assert_lines_lint(
+            ["BUGWK1 WIN : passes/text.html = PASS",
+             "BUGWK1 MAC : passes/text.html = TIMEOUT"],
+            "")
+
+        self.assert_lines_lint(
+            ["BUGWK1 LEOPARD DEBUG : passes/text.html = PASS",
+             "BUGWK1 LEOPARD RELEASE : passes/text.html = TIMEOUT"],
+            "")
+
+
     def test_tab(self):
         self.assert_lines_lint(
             ["\tBUGWK1 : passes/text.html = PASS"],
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to