Changeset 90934 in webkit


Ignore:
Timestamp:
Jul 13, 2011 11:40:12 AM (13 years ago)
Author:
Dimitri Glazkov
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.

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r90932 r90934  
     12011-07-13  Dimitri Glazkov  <dglazkov@chromium.org>
     2
     3        Eliminate TestExpectationsFile.
     4        https://bugs.webkit.org/show_bug.cgi?id=64458
     5
     6        Turns out, we can just use a Python list.
     7
     8        Reviewed by Adam Barth.
     9
     10        * Scripts/webkitpy/layout_tests/models/test_expectations.py: Folded TestExpectationsFile.append into TestExpectationParser.parse_list,
     11            removed TestExpectationsFile.
     12        * Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py: Moved tests to better reflect new names, removed iterator test,
     13            since there's no more custom iterator machinery.
     14
    1152011-07-13  Philippe Normand  <pnormand@igalia.com>
    216
  • trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py

    r90920 r90934  
    196196
    197197    @classmethod
     198    def parse_list(cls, expectations_string, validator):
     199        """Returns a list of TestExpectationLines, one for each line in expectations_string."""
     200        expectations = []
     201        line_number = 0
     202        for line in expectations_string.split("\n"):
     203            expectation, errors = cls.parse(line)
     204            line_number += 1
     205            expectation.valid = validator.validate(line_number, expectation, errors)
     206            expectations.append(expectation)
     207        return expectations
     208
     209    @classmethod
    198210    def _split_expectation_string(cls, line, errors):
    199211        """Splits line into a string of modifiers, a test name, a string of expectations, and a comment,
     
    243255        self.valid = False
    244256        self.malformed = False
    245 
    246 
    247 class TestExpectationsFile:
    248     """Represents a test expectation file, which is a mutable collection of comments and test expectations."""
    249 
    250     def __init__(self):
    251         self._expectations = []
    252 
    253     def __iter__(self):
    254         return self._expectations.__iter__()
    255 
    256     def append(self, expectations_string, validator):
    257         """Add a TestExpectationLine for each item in expectations_string."""
    258         line_number = 0
    259         for line in expectations_string.split("\n"):
    260             expectation, errors = TestExpectationParser.parse(line)
    261             line_number += 1
    262             expectation.valid = validator.validate(line_number, expectation, errors)
    263             self._expectations.append(expectation)
    264257
    265258
     
    401394
    402395        self._matcher = ModifierMatcher(self._test_config)
    403         self._expectations = TestExpectationsFile()
    404396        self._overrides_allowed = False
    405         self._expectations.append(expectations, self)
     397        self._expectations = TestExpectationParser.parse_list(expectations, self)
    406398
    407399        # List of tests that are in the overrides file (used for checking for
     
    414406        if overrides:
    415407            self._overrides_allowed = True
    416             self._expectations.append(self._overrides, self)
     408            self._expectations += TestExpectationParser.parse_list(self._overrides, self)
    417409            self._overrides_allowed = False
    418410
  • trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py

    r90920 r90934  
    537537        self.assertEqual(len(errors), 0)
    538538
     539    def test_line_number_increment(self):
     540        validator = TestValidator()
     541        expectations = TestExpectationParser.parse_list('// Bar\nFOO : bar = BAZ\n\n', validator)
     542        self.assertEqual(str(validator.line_numbers), '[1, 2, 3, 4]')
     543
     544    def test_validator_feedback(self):
     545        validator = TestValidator()
     546        expectations = TestExpectationParser.parse_list('FOO : bar1 = BAZ\nFOO : bar2 = BAZ\nFOO : bar3 = BAZ', validator)
     547        line_number = 0
     548        for expectation in expectations:
     549            line_number += 1
     550            self.assertEqual(line_number % 2 == 0, expectation.valid)
     551
    539552
    540553class TestExpectationSerializerTests(unittest.TestCase):
     
    608621        return line_number % 2 == 0
    609622
    610 
    611 class TestExpectationsFileTests(unittest.TestCase):
    612     def test_line_number_increment(self):
    613         validator = TestValidator()
    614         expectations = TestExpectationsFile()
    615         expectations.append('// Bar\nFOO : bar = BAZ\n\n', validator)
    616         self.assertEqual(str(validator.line_numbers), '[1, 2, 3, 4]')
    617 
    618     def test_iterator(self):
    619         validator = TestValidator()
    620         expectations = TestExpectationsFile()
    621         expectations.append('\n\n\n\n', validator)
    622         line_number = 0
    623         for expectation in expectations:
    624             line_number += 1
    625         self.assertEqual(line_number, 5)
    626 
    627     def test_validator_feedback(self):
    628         validator = TestValidator()
    629         expectations = TestExpectationsFile()
    630         expectations.append('FOO : bar1 = BAZ\nFOO : bar2 = BAZ\nFOO : bar3 = BAZ', validator)
    631         line_number = 0
    632         for expectation in expectations:
    633             line_number += 1
    634             self.assertEqual(line_number % 2 == 0, expectation.valid)
    635 
    636623if __name__ == '__main__':
    637624    unittest.main()
Note: See TracChangeset for help on using the changeset viewer.