Title: [90941] trunk/Tools
Revision
90941
Author
[email protected]
Date
2011-07-13 12:36:47 -0700 (Wed, 13 Jul 2011)

Log Message

Consolidate expectations parsing code.
https://bugs.webkit.org/show_bug.cgi?id=64460

Reviewed by Adam Barth.

* Scripts/webkitpy/layout_tests/models/test_expectations.py: Folded TestExpectationParser._split_expectation_string into TestExpectationParser.parse.

Modified Paths

Diff

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


--- trunk/Tools/ChangeLog	2011-07-13 19:31:52 UTC (rev 90940)
+++ trunk/Tools/ChangeLog	2011-07-13 19:36:47 UTC (rev 90941)
@@ -1,3 +1,12 @@
+2011-07-13  Dimitri Glazkov  <[email protected]>
+
+        Consolidate expectations parsing code.
+        https://bugs.webkit.org/show_bug.cgi?id=64460
+
+        Reviewed by Adam Barth.
+
+        * Scripts/webkitpy/layout_tests/models/test_expectations.py: Folded TestExpectationParser._split_expectation_string into TestExpectationParser.parse.
+
 2011-07-12  Brent Fulgham  <[email protected]>
 
         Standardize WinCairo conditionalized code under PLATFORM macro.

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2011-07-13 19:31:52 UTC (rev 90940)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2011-07-13 19:36:47 UTC (rev 90941)
@@ -173,26 +173,40 @@
         Any errant whitespace is not preserved.
 
         """
-        result = TestExpectationLine()
+        expectation = TestExpectationLine()
         errors = []
-        (modifiers, name, expectations, comment) = cls._split_expectation_string(expectation_string, errors)
+        comment_index = expectation_string.find("//")
+        if comment_index == -1:
+            comment_index = len(expectation_string)
+        else:
+            expectation.comment = expectation_string[comment_index + 2:]
+
+        remaining_string = re.sub(r"\s+", " ", expectation_string[:comment_index].strip())
+        if len(remaining_string) == 0:
+            expectation.malformed = False
+            expectation.valid = True
+            return expectation, errors
+
+        parts = remaining_string.split(':')
+        if len(parts) != 2:
+            errors.append(("Missing a ':' in" if len(parts) < 2 else "Extraneous ':' in", "'" + expectation_string + "'"))
+        else:
+            test_and_expectation = parts[1].split('=')
+            if len(test_and_expectation) != 2:
+                errors.append(("Missing expectations in" if len(test_and_expectation) < 2 else "Extraneous '=' in", "'" + expectation_string + "'"))
+
         if len(errors) > 0:
-            result.malformed = True
-            result.comment = expectation_string
-            result.valid = False
+            expectation.comment = expectation_string
+            expectation.malformed = True
+            expectation.valid = False
         else:
-            result.malformed = False
-            result.comment = comment
-            result.valid = True
-            result.name = name
-            # FIXME: Modifiers should be its own class eventually.
-            if modifiers is not None:
-                result.modifiers = cls._split_space_separated(modifiers)
-            # FIXME: Expectations should be its own class eventually.
-            if expectations is not None:
-                result.expectations = cls._split_space_separated(expectations)
+            expectation.malformed = False
+            expectation.valid = True
+            expectation.modifiers = cls._split_space_separated(parts[0])
+            expectation.name = test_and_expectation[0].strip()
+            expectation.expectations = cls._split_space_separated(test_and_expectation[1])
 
-        return (result, errors)
+        return expectation, errors
 
     @classmethod
     def parse_list(cls, expectations_string, validator):
@@ -207,35 +221,6 @@
         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.
-        """
-        comment_index = line.find("//")
-        comment = ''
-        if comment_index == -1:
-            comment_index = len(line)
-            comment = None
-        else:
-            comment = line[comment_index + 2:]
-
-        line = re.sub(r"\s+", " ", line[:comment_index].strip())
-        if len(line) == 0:
-            return (None, None, None, comment)
-
-        parts = line.split(':')
-        if len(parts) != 2:
-            errors.append(("Missing a ':' in" if len(parts) < 2 else "Extraneous ':' in", "'" + line + "'"))
-            return (None, None, None, None)
-
-        test_and_expectation = parts[1].split('=')
-        if len(test_and_expectation) != 2:
-            errors.append(("Missing expectations in" if len(test_and_expectation) < 2 else "Extraneous '=' in", "'" + line + "'"))
-            return (None, None, None, None)
-
-        return (parts[0].strip(), test_and_expectation[0].strip(), test_and_expectation[1].strip(), comment)
-
-    @classmethod
     def _split_space_separated(cls, space_separated_string):
         """Splits a space-separated string into an array."""
         # FIXME: Lower-casing is necessary to support legacy code. Need to eliminate.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to