Title: [90934] trunk/Tools
Revision
90934
Author
[email protected]
Date
2011-07-13 11:40:12 -0700 (Wed, 13 Jul 2011)

Log Message

Eliminate TestExpectationsFile.
https://bugs.webkit.org/show_bug.cgi?id=64458

Turns out, we can just use a Python list.

Reviewed by Adam Barth.

* Scripts/webkitpy/layout_tests/models/test_expectations.py: Folded TestExpectationsFile.append into TestExpectationParser.parse_list,
    removed TestExpectationsFile.
* Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py: Moved tests to better reflect new names, removed iterator test,
    since there's no more custom iterator machinery.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (90933 => 90934)


--- trunk/Tools/ChangeLog	2011-07-13 17:55:20 UTC (rev 90933)
+++ trunk/Tools/ChangeLog	2011-07-13 18:40:12 UTC (rev 90934)
@@ -1,3 +1,17 @@
+2011-07-13  Dimitri Glazkov  <[email protected]>
+
+        Eliminate TestExpectationsFile.
+        https://bugs.webkit.org/show_bug.cgi?id=64458
+
+        Turns out, we can just use a Python list.
+
+        Reviewed by Adam Barth.
+
+        * Scripts/webkitpy/layout_tests/models/test_expectations.py: Folded TestExpectationsFile.append into TestExpectationParser.parse_list,
+            removed TestExpectationsFile.
+        * Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py: Moved tests to better reflect new names, removed iterator test,
+            since there's no more custom iterator machinery.
+
 2011-07-13  Philippe Normand  <[email protected]>
 
         Unreviewed, added my other email addresses.

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2011-07-13 17:55:20 UTC (rev 90933)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2011-07-13 18:40:12 UTC (rev 90934)
@@ -195,6 +195,18 @@
         return (result, errors)
 
     @classmethod
+    def parse_list(cls, expectations_string, validator):
+        """Returns a list of TestExpectationLines, one for each line in expectations_string."""
+        expectations = []
+        line_number = 0
+        for line in expectations_string.split("\n"):
+            expectation, errors = cls.parse(line)
+            line_number += 1
+            expectation.valid = validator.validate(line_number, expectation, errors)
+            expectations.append(expectation)
+        return expectations
+
+    @classmethod
     def _split_expectation_string(cls, line, errors):
         """Splits line into a string of modifiers, a test name, a string of expectations, and a comment,
         returning them as a tuple. In case parsing error, returns empty tuple.
@@ -244,25 +256,6 @@
         self.malformed = False
 
 
-class TestExpectationsFile:
-    """Represents a test expectation file, which is a mutable collection of comments and test expectations."""
-
-    def __init__(self):
-        self._expectations = []
-
-    def __iter__(self):
-        return self._expectations.__iter__()
-
-    def append(self, expectations_string, validator):
-        """Add a TestExpectationLine for each item in expectations_string."""
-        line_number = 0
-        for line in expectations_string.split("\n"):
-            expectation, errors = TestExpectationParser.parse(line)
-            line_number += 1
-            expectation.valid = validator.validate(line_number, expectation, errors)
-            self._expectations.append(expectation)
-
-
 class TestExpectations:
     """Test expectations consist of lines with specifications of what
     to expect from layout test cases. The test cases can be directories
@@ -400,9 +393,8 @@
         self._result_type_to_tests = self._dict_of_sets(self.RESULT_TYPES)
 
         self._matcher = ModifierMatcher(self._test_config)
-        self._expectations = TestExpectationsFile()
         self._overrides_allowed = False
-        self._expectations.append(expectations, self)
+        self._expectations = TestExpectationParser.parse_list(expectations, self)
 
         # List of tests that are in the overrides file (used for checking for
         # duplicates inside the overrides file itself). Note that just because
@@ -413,7 +405,7 @@
 
         if overrides:
             self._overrides_allowed = True
-            self._expectations.append(self._overrides, self)
+            self._expectations += TestExpectationParser.parse_list(self._overrides, self)
             self._overrides_allowed = False
 
         self._handle_any_read_errors()

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py (90933 => 90934)


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py	2011-07-13 17:55:20 UTC (rev 90933)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py	2011-07-13 18:40:12 UTC (rev 90934)
@@ -536,7 +536,20 @@
         self.assertEqual(str(expectation.expectations), '[\'baz\']')
         self.assertEqual(len(errors), 0)
 
+    def test_line_number_increment(self):
+        validator = TestValidator()
+        expectations = TestExpectationParser.parse_list('// Bar\nFOO : bar = BAZ\n\n', validator)
+        self.assertEqual(str(validator.line_numbers), '[1, 2, 3, 4]')
 
+    def test_validator_feedback(self):
+        validator = TestValidator()
+        expectations = TestExpectationParser.parse_list('FOO : bar1 = BAZ\nFOO : bar2 = BAZ\nFOO : bar3 = BAZ', validator)
+        line_number = 0
+        for expectation in expectations:
+            line_number += 1
+            self.assertEqual(line_number % 2 == 0, expectation.valid)
+
+
 class TestExpectationSerializerTests(unittest.TestCase):
     def assert_round_trip(self, in_string, expected_string=None):
         (expectation, _) = TestExpectationParser.parse(in_string)
@@ -607,31 +620,5 @@
         self.line_numbers.append(line_number)
         return line_number % 2 == 0
 
-
-class TestExpectationsFileTests(unittest.TestCase):
-    def test_line_number_increment(self):
-        validator = TestValidator()
-        expectations = TestExpectationsFile()
-        expectations.append('// Bar\nFOO : bar = BAZ\n\n', validator)
-        self.assertEqual(str(validator.line_numbers), '[1, 2, 3, 4]')
-
-    def test_iterator(self):
-        validator = TestValidator()
-        expectations = TestExpectationsFile()
-        expectations.append('\n\n\n\n', validator)
-        line_number = 0
-        for expectation in expectations:
-            line_number += 1
-        self.assertEqual(line_number, 5)
-
-    def test_validator_feedback(self):
-        validator = TestValidator()
-        expectations = TestExpectationsFile()
-        expectations.append('FOO : bar1 = BAZ\nFOO : bar2 = BAZ\nFOO : bar3 = BAZ', validator)
-        line_number = 0
-        for expectation in expectations:
-            line_number += 1
-            self.assertEqual(line_number % 2 == 0, expectation.valid)
-
 if __name__ == '__main__':
     unittest.main()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to