webkitpy: drop support for old TestExpectations syntax
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Sep 2012 22:35:50 +0000 (22:35 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Sep 2012 22:35:50 +0000 (22:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97364

Reviewed by Ryosuke Niwa.

* Scripts/webkitpy/layout_tests/models/test_expectations.py:
(TestExpectationParser._collect_matching_tests):
(TestExpectationParser):
(TestExpectationParser._tokenize_line):
* Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
(SkippedTests.test_skipped_entry_dont_exist):
(ExpectationSyntaxTests.assert_tokenize_exp):
(ExpectationSyntaxTests.test_bare_name):
(ExpectationSyntaxTests.test_bare_name_and_bugs):
(ExpectationSyntaxTests.test_comments):
(ExpectationSyntaxTests.test_config_modifiers):
(ExpectationSyntaxTests.test_unknown_config):
(ExpectationSyntaxTests.test_unknown_expectation):
(ExpectationSyntaxTests.test_skip):
(ExpectationSyntaxTests.test_slow):
(ExpectationSyntaxTests.test_wontfix):
(ExpectationSyntaxTests.test_blank_line):
(ExpectationSyntaxTests.test_warnings):
(RebaseliningTest.test_no_get_rebaselining_failures):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@129265 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py

index 00ec4e1..a0321b5 100644 (file)
@@ -1,3 +1,30 @@
+2012-09-21  Dirk Pranke  <dpranke@chromium.org>
+
+        webkitpy: drop support for old TestExpectations syntax
+        https://bugs.webkit.org/show_bug.cgi?id=97364
+
+        Reviewed by Ryosuke Niwa.
+
+        * Scripts/webkitpy/layout_tests/models/test_expectations.py:
+        (TestExpectationParser._collect_matching_tests):
+        (TestExpectationParser):
+        (TestExpectationParser._tokenize_line):
+        * Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
+        (SkippedTests.test_skipped_entry_dont_exist):
+        (ExpectationSyntaxTests.assert_tokenize_exp):
+        (ExpectationSyntaxTests.test_bare_name):
+        (ExpectationSyntaxTests.test_bare_name_and_bugs):
+        (ExpectationSyntaxTests.test_comments):
+        (ExpectationSyntaxTests.test_config_modifiers):
+        (ExpectationSyntaxTests.test_unknown_config):
+        (ExpectationSyntaxTests.test_unknown_expectation):
+        (ExpectationSyntaxTests.test_skip):
+        (ExpectationSyntaxTests.test_slow):
+        (ExpectationSyntaxTests.test_wontfix):
+        (ExpectationSyntaxTests.test_blank_line):
+        (ExpectationSyntaxTests.test_warnings):
+        (RebaseliningTest.test_no_get_rebaselining_failures):
+
 2012-09-21  Simon Fraser  <simon.fraser@apple.com>
 
         Improve WTR unresponsiveness output a little
index 85e8d17..42b518f 100644 (file)
@@ -208,56 +208,6 @@ class TestExpectationParser(object):
         if expectation_line.path in self._full_test_list:
             expectation_line.matching_tests.append(expectation_line.path)
 
-    # FIXME: Seems like these should be classmethods on TestExpectationLine instead of TestExpectationParser.
-    @classmethod
-    def _tokenize_line(cls, filename, expectation_string, line_number):
-        expectation_line = cls._tokenize_line_using_new_format(filename, expectation_string, line_number)
-        if expectation_line.is_invalid():
-            old_expectation_line = cls._tokenize_line_using_old_format(filename, expectation_string, line_number)
-            if not old_expectation_line.is_invalid():
-                return old_expectation_line
-        return expectation_line
-
-    @classmethod
-    def _tokenize_line_using_old_format(cls, filename, expectation_string, line_number):
-        """Tokenizes a line from TestExpectations and returns an unparsed TestExpectationLine instance.
-
-        The format of a test expectation line is:
-
-        [[<modifiers>] : <name> = <expectations>][ //<comment>]
-
-        Any errant whitespace is not preserved.
-
-        """
-        expectation_line = TestExpectationLine()
-        expectation_line.original_string = expectation_string
-        expectation_line.line_number = line_number
-        expectation_line.filename = filename
-        comment_index = expectation_string.find("//")
-        if comment_index == -1:
-            comment_index = len(expectation_string)
-        else:
-            expectation_line.comment = expectation_string[comment_index + 2:]
-
-        remaining_string = re.sub(r"\s+", " ", expectation_string[:comment_index].strip())
-        if len(remaining_string) == 0:
-            return expectation_line
-
-        parts = remaining_string.split(':')
-        if len(parts) != 2:
-            expectation_line.warnings.append("Missing a ':'" if len(parts) < 2 else "Extraneous ':'")
-        else:
-            test_and_expectation = parts[1].split('=')
-            if len(test_and_expectation) != 2:
-                expectation_line.warnings.append("Missing expectations" if len(test_and_expectation) < 2 else "Extraneous '='")
-
-        if not expectation_line.is_invalid():
-            expectation_line.modifiers = cls._split_space_separated(parts[0])
-            expectation_line.name = test_and_expectation[0].strip()
-            expectation_line.expectations = cls._split_space_separated(test_and_expectation[1])
-
-        return expectation_line
-
     # FIXME: Update the original modifiers and remove this once the old syntax is gone.
     _configuration_tokens_list = [
         'Mac', 'SnowLeopard', 'Lion', 'MountainLion',
@@ -288,8 +238,9 @@ class TestExpectationParser(object):
     _inverted_expectation_tokens = dict([(value, name) for name, value in _expectation_tokens.iteritems()] +
                                         [('TEXT', 'Failure'), ('IMAGE+TEXT', 'Failure'), ('AUDIO', 'Failure')])
 
+    # FIXME: Seems like these should be classmethods on TestExpectationLine instead of TestExpectationParser.
     @classmethod
-    def _tokenize_line_using_new_format(cls, filename, expectation_string, line_number):
+    def _tokenize_line(cls, filename, expectation_string, line_number):
         """Tokenizes a line from TestExpectations and returns an unparsed TestExpectationLine instance using the old format.
 
         The new format for a test expectation line is:
index ea40dfb..c560607 100644 (file)
@@ -290,24 +290,7 @@ class SkippedTests(Base):
         self.assertEqual('The following test foo/bar/baz.html from the Skipped list doesn\'t exist\n', logs)
 
 
-# FIXME: remove these tests when we stop supporting the old syntax.
-
 class ExpectationSyntaxTests(Base):
-    def disabled_test_missing_expectation(self):
-        # This is missing the expectation.
-        self.assert_bad_expectations('BUG_TEST: failures/expected/text.html')
-
-    def disabled_test_missing_colon(self):
-        # This is missing the modifiers and the ':'
-        self.assert_bad_expectations('failures/expected/text.html [ Failure ]')
-
-    def disabled_test_too_many_colons(self):
-        self.assert_bad_expectations('BUG_TEST: failures/expected/text.html = PASS :')
-
-    def disabled_test_too_many_equals_signs(self):
-        self.assert_bad_expectations('BUG_TEST: failures/expected/text.html = FAIL = IMAGE')
-
-    # Keep these two
     def test_unrecognized_expectation(self):
         self.assert_bad_expectations('Bug(test) failures/expected/text.html [ Unknown ]')
 
@@ -316,17 +299,14 @@ class ExpectationSyntaxTests(Base):
         self.parse_exp(exp_str)
         self.assert_exp('failures/expected/text.html', FAIL)
 
-
-
-class NewExpectationSyntaxTests(unittest.TestCase):
-    def assert_exp(self, line, bugs=None, modifiers=None, expectations=None, warnings=None, comment=None, name='foo.html'):
+    def assert_tokenize_exp(self, line, bugs=None, modifiers=None, expectations=None, warnings=None, comment=None, name='foo.html'):
         bugs = bugs or []
         modifiers = modifiers or []
         expectations = expectations or []
         warnings = warnings or []
         filename = 'TestExpectations'
         line_number = 1
-        expectation_line = TestExpectationParser._tokenize_line_using_new_format(filename, line, line_number)
+        expectation_line = TestExpectationParser._tokenize_line(filename, line, line_number)
         self.assertEquals(expectation_line.warnings, warnings)
         self.assertEquals(expectation_line.name, name)
         self.assertEquals(expectation_line.filename, filename)
@@ -336,47 +316,47 @@ class NewExpectationSyntaxTests(unittest.TestCase):
             self.assertEquals(expectation_line.expectations, expectations)
 
     def test_bare_name(self):
-        self.assert_exp('foo.html', modifiers=['SKIP'], expectations=['PASS'])
+        self.assert_tokenize_exp('foo.html', modifiers=['SKIP'], expectations=['PASS'])
 
     def test_bare_name_and_bugs(self):
-        self.assert_exp('webkit.org/b/12345 foo.html', modifiers=['BUGWK12345', 'SKIP'], expectations=['PASS'])
-        self.assert_exp('crbug.com/12345 foo.html', modifiers=['BUGCR12345', 'SKIP'], expectations=['PASS'])
-        self.assert_exp('Bug(dpranke) foo.html', modifiers=['BUGDPRANKE', 'SKIP'], expectations=['PASS'])
-        self.assert_exp('crbug.com/12345 crbug.com/34567 foo.html', modifiers=['BUGCR12345', 'BUGCR34567', 'SKIP'], expectations=['PASS'])
+        self.assert_tokenize_exp('webkit.org/b/12345 foo.html', modifiers=['BUGWK12345', 'SKIP'], expectations=['PASS'])
+        self.assert_tokenize_exp('crbug.com/12345 foo.html', modifiers=['BUGCR12345', 'SKIP'], expectations=['PASS'])
+        self.assert_tokenize_exp('Bug(dpranke) foo.html', modifiers=['BUGDPRANKE', 'SKIP'], expectations=['PASS'])
+        self.assert_tokenize_exp('crbug.com/12345 crbug.com/34567 foo.html', modifiers=['BUGCR12345', 'BUGCR34567', 'SKIP'], expectations=['PASS'])
 
     def test_comments(self):
-        self.assert_exp("# comment", name=None, comment="# comment")
-        self.assert_exp("foo.html # comment", comment="# comment", expectations=['PASS'], modifiers=['SKIP'])
+        self.assert_tokenize_exp("# comment", name=None, comment="# comment")
+        self.assert_tokenize_exp("foo.html # comment", comment="# comment", expectations=['PASS'], modifiers=['SKIP'])
 
     def test_config_modifiers(self):
-        self.assert_exp('[ Mac ] foo.html', modifiers=['MAC', 'SKIP'], expectations=['PASS'])
-        self.assert_exp('[ Mac Vista ] foo.html', modifiers=['MAC', 'VISTA', 'SKIP'], expectations=['PASS'])
-        self.assert_exp('[ Mac ] foo.html [ Failure ] ', modifiers=['MAC'], expectations=['FAIL'])
+        self.assert_tokenize_exp('[ Mac ] foo.html', modifiers=['MAC', 'SKIP'], expectations=['PASS'])
+        self.assert_tokenize_exp('[ Mac Vista ] foo.html', modifiers=['MAC', 'VISTA', 'SKIP'], expectations=['PASS'])
+        self.assert_tokenize_exp('[ Mac ] foo.html [ Failure ] ', modifiers=['MAC'], expectations=['FAIL'])
 
     def test_unknown_config(self):
-        self.assert_exp('[ Foo ] foo.html ', modifiers=['Foo', 'SKIP'], expectations=['PASS'])
+        self.assert_tokenize_exp('[ Foo ] foo.html ', modifiers=['Foo', 'SKIP'], expectations=['PASS'])
 
     def test_unknown_expectation(self):
-        self.assert_exp('foo.html [ Audio ]', expectations=['Audio'])
+        self.assert_tokenize_exp('foo.html [ Audio ]', expectations=['Audio'])
 
     def test_skip(self):
-        self.assert_exp('foo.html [ Skip ]', modifiers=['SKIP'], expectations=['PASS'])
+        self.assert_tokenize_exp('foo.html [ Skip ]', modifiers=['SKIP'], expectations=['PASS'])
 
     def test_slow(self):
-        self.assert_exp('foo.html [ Slow ]', modifiers=['SLOW'], expectations=['PASS'])
+        self.assert_tokenize_exp('foo.html [ Slow ]', modifiers=['SLOW'], expectations=['PASS'])
 
     def test_wontfix(self):
-        self.assert_exp('foo.html [ WontFix ]', modifiers=['WONTFIX', 'SKIP'], expectations=['PASS'])
+        self.assert_tokenize_exp('foo.html [ WontFix ]', modifiers=['WONTFIX', 'SKIP'], expectations=['PASS'])
 
     def test_blank_line(self):
-        self.assert_exp('', name=None)
+        self.assert_tokenize_exp('', name=None)
 
     def test_warnings(self):
-        self.assert_exp('[ Mac ]', warnings=['Did not find a test name.'], name=None)
-        self.assert_exp('[ [', warnings=['unexpected "["'], name=None)
-        self.assert_exp('crbug.com/12345 ]', warnings=['unexpected "]"'], name=None)
+        self.assert_tokenize_exp('[ Mac ]', warnings=['Did not find a test name.'], name=None)
+        self.assert_tokenize_exp('[ [', warnings=['unexpected "["'], name=None)
+        self.assert_tokenize_exp('crbug.com/12345 ]', warnings=['unexpected "]"'], name=None)
 
-        self.assert_exp('foo.html crbug.com/12345 ]', warnings=['"crbug.com/12345" is not at the start of the line.'])
+        self.assert_tokenize_exp('foo.html crbug.com/12345 ]', warnings=['"crbug.com/12345" is not at the start of the line.'])
 
 
 class SemanticTests(Base):
@@ -538,69 +518,6 @@ class RebaseliningTest(Base):
         self.assertEqual(len(self._exp.get_rebaselining_failures()), 0)
 
 
-# FIXME: remove most of these tests when we no longer support the old syntax.
-
-class OldExpectationParserTests(unittest.TestCase):
-    def _tokenize(self, line):
-        return TestExpectationParser._tokenize_line_using_old_format('path', line, 0)
-
-    def test_tokenize_blank(self):
-        expectation = self._tokenize('')
-        self.assertEqual(expectation.comment, None)
-        self.assertEqual(len(expectation.warnings), 0)
-
-    def test_tokenize_extra_colon(self):
-        expectation = self._tokenize('FOO : : bar')
-        self.assertEqual(expectation.warnings, ["Extraneous ':'"])
-
-    def test_tokenize_empty_comment(self):
-        expectation = self._tokenize('//')
-        self.assertEqual(expectation.comment, '')
-        self.assertEqual(len(expectation.warnings), 0)
-
-    def test_tokenize_comment(self):
-        expectation = self._tokenize('//Qux.')
-        self.assertEqual(expectation.comment, 'Qux.')
-        self.assertEqual(len(expectation.warnings), 0)
-
-    def test_tokenize_missing_equal(self):
-        expectation = self._tokenize('FOO : bar')
-        self.assertEqual(expectation.warnings, ['Missing expectations'])
-
-    def test_tokenize_extra_equal(self):
-        expectation = self._tokenize('FOO : bar = BAZ = Qux.')
-        self.assertEqual(expectation.warnings, ["Extraneous '='"])
-
-    def test_tokenize_valid(self):
-        expectation = self._tokenize('FOO : bar = BAZ')
-        self.assertEqual(expectation.comment, None)
-        self.assertEqual(len(expectation.warnings), 0)
-
-    def test_tokenize_valid_with_comment(self):
-        expectation = self._tokenize('FOO : bar = BAZ //Qux.')
-        self.assertEqual(expectation.comment, 'Qux.')
-        self.assertEqual(str(expectation.modifiers), "['FOO']")
-        self.assertEqual(str(expectation.expectations), "['BAZ']")
-        self.assertEqual(len(expectation.warnings), 0)
-
-    def test_tokenize_valid_with_multiple_modifiers(self):
-        expectation = self._tokenize('FOO1 FOO2 : bar = BAZ //Qux.')
-        self.assertEqual(expectation.comment, 'Qux.')
-        self.assertEqual(str(expectation.modifiers), "['FOO1', 'FOO2']")
-        self.assertEqual(str(expectation.expectations), "['BAZ']")
-        self.assertEqual(len(expectation.warnings), 0)
-
-    def test_parse_empty_string(self):
-        host = MockHost()
-        test_port = host.port_factory.get('test-win-xp', None)
-        test_port.test_exists = lambda test: True
-        full_test_list = []
-        expectation_line = self._tokenize('')
-        parser = TestExpectationParser(test_port, full_test_list, allow_rebaseline_modifier=False)
-        parser._parse_line(expectation_line)
-        self.assertFalse(expectation_line.is_invalid())
-
-
 class TestExpectationSerializationTests(unittest.TestCase):
     def __init__(self, testFunc):
         host = MockHost()