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

Log 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.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (90941 => 90942)


--- trunk/Tools/ChangeLog	2011-07-13 19:36:47 UTC (rev 90941)
+++ trunk/Tools/ChangeLog	2011-07-13 19:40:09 UTC (rev 90942)
@@ -1,5 +1,15 @@
 2011-07-13  Dimitri Glazkov  <[email protected]>
 
+        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.
+
+2011-07-13  Dimitri Glazkov  <[email protected]>
+
         Consolidate expectations parsing code.
         https://bugs.webkit.org/show_bug.cgi?id=64460
 

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2011-07-13 19:36:47 UTC (rev 90941)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2011-07-13 19:40:09 UTC (rev 90942)
@@ -157,7 +157,11 @@
 
         return ''.join(result)
 
+    @classmethod
+    def list_to_string(cls, expectations):
+        return "\n".join([TestExpectationSerializer.to_string(expectation) for expectation in expectations])
 
+
 class TestExpectationParser:
     """Provides parsing facilities for lines in the test_expectation.txt file."""
 
@@ -507,12 +511,11 @@
 
     def remove_rebaselined_tests(self, tests):
         """Returns a copy of the expectations with the tests removed."""
-        lines = []
-        for expectation in self._expectations:
-            if not (expectation.valid and expectation.name in tests and "rebaseline" in expectation.modifiers):
-                lines.append(TestExpectationSerializer.to_string(expectation))
-        return "\n".join(lines)
+        def without_rebaseline_modifier(expectation):
+            return not (expectation.valid and expectation.name in tests and "rebaseline" in expectation.modifiers)
 
+        return TestExpectationSerializer.list_to_string(filter(without_rebaseline_modifier, self._expectations))
+
     def _add_to_all_expectations(self, test, options, expectations):
         if not test in self._all_expectations:
             self._all_expectations[test] = []

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py	2011-07-13 19:36:47 UTC (rev 90941)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py	2011-07-13 19:40:09 UTC (rev 90942)
@@ -557,6 +557,12 @@
             expected_string = in_string
         self.assertEqual(expected_string, TestExpectationSerializer.to_string(expectation))
 
+    def assert_list_round_trip(self, in_string, expected_string=None):
+        expectations = TestExpectationParser.parse_list(in_string, TestValidator())
+        if expected_string is None:
+            expected_string = in_string
+        self.assertEqual(expected_string, TestExpectationSerializer.list_to_string(expectations))
+
     def assert_to_string(self, expectation, expected_string):
         self.assertEqual(TestExpectationSerializer.to_string(expectation), expected_string)
 
@@ -602,6 +608,14 @@
         self.assert_round_trip('// Foo :')
         self.assert_round_trip('// Foo : =')
 
+    def test_list_roundtrip(self):
+        self.assert_list_round_trip('')
+        self.assert_list_round_trip('\n')
+        self.assert_list_round_trip('\n\n')
+        self.assert_list_round_trip('bar')
+        self.assert_list_round_trip('bar\n//Qux.')
+        self.assert_list_round_trip('bar\n//Qux.\n')
+
     def test_string_whitespace_stripping(self):
         self.assert_round_trip('\n', '')
         self.assert_round_trip('  FOO : bar = BAZ', 'FOO : bar = BAZ')
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to