Changeset 90942 in webkit


Ignore:
Timestamp:
Jul 13, 2011 12:40:09 PM (13 years ago)
Author:
Dimitri Glazkov
Message:

Introduce TestExpectationSerializer.list_to_string.
https://bugs.webkit.org/show_bug.cgi?id=64462

Reviewed by Adam Barth.

  • Scripts/webkitpy/layout_tests/models/test_expectations.py: Added list_to_string and change the relevant callsite to use it.
  • Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py: Added tests for it.
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r90941 r90942  
     12011-07-13  Dimitri Glazkov  <dglazkov@chromium.org>
     2
     3        Introduce TestExpectationSerializer.list_to_string.
     4        https://bugs.webkit.org/show_bug.cgi?id=64462
     5
     6        Reviewed by Adam Barth.
     7
     8        * Scripts/webkitpy/layout_tests/models/test_expectations.py: Added list_to_string and change the relevant callsite to use it.
     9        * Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py: Added tests for it.
     10
    1112011-07-13  Dimitri Glazkov  <dglazkov@chromium.org>
    212
  • trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py

    r90941 r90942  
    158158        return ''.join(result)
    159159
     160    @classmethod
     161    def list_to_string(cls, expectations):
     162        return "\n".join([TestExpectationSerializer.to_string(expectation) for expectation in expectations])
     163
    160164
    161165class TestExpectationParser:
     
    508512    def remove_rebaselined_tests(self, tests):
    509513        """Returns a copy of the expectations with the tests removed."""
    510         lines = []
    511         for expectation in self._expectations:
    512             if not (expectation.valid and expectation.name in tests and "rebaseline" in expectation.modifiers):
    513                 lines.append(TestExpectationSerializer.to_string(expectation))
    514         return "\n".join(lines)
     514        def without_rebaseline_modifier(expectation):
     515            return not (expectation.valid and expectation.name in tests and "rebaseline" in expectation.modifiers)
     516
     517        return TestExpectationSerializer.list_to_string(filter(without_rebaseline_modifier, self._expectations))
    515518
    516519    def _add_to_all_expectations(self, test, options, expectations):
  • trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py

    r90934 r90942  
    558558        self.assertEqual(expected_string, TestExpectationSerializer.to_string(expectation))
    559559
     560    def assert_list_round_trip(self, in_string, expected_string=None):
     561        expectations = TestExpectationParser.parse_list(in_string, TestValidator())
     562        if expected_string is None:
     563            expected_string = in_string
     564        self.assertEqual(expected_string, TestExpectationSerializer.list_to_string(expectations))
     565
    560566    def assert_to_string(self, expectation, expected_string):
    561567        self.assertEqual(TestExpectationSerializer.to_string(expectation), expected_string)
     
    603609        self.assert_round_trip('// Foo : =')
    604610
     611    def test_list_roundtrip(self):
     612        self.assert_list_round_trip('')
     613        self.assert_list_round_trip('\n')
     614        self.assert_list_round_trip('\n\n')
     615        self.assert_list_round_trip('bar')
     616        self.assert_list_round_trip('bar\n//Qux.')
     617        self.assert_list_round_trip('bar\n//Qux.\n')
     618
    605619    def test_string_whitespace_stripping(self):
    606620        self.assert_round_trip('\n', '')
Note: See TracChangeset for help on using the changeset viewer.