Title: [132530] trunk/Tools
Revision
132530
Author
[email protected]
Date
2012-10-25 13:51:26 -0700 (Thu, 25 Oct 2012)

Log Message

rwt --lint-test-files doesn't handle the cascade properly
https://bugs.webkit.org/show_bug.cgi?id=100315

Reviewed by Ojan Vafai.

We were only linting the first file in each port's list of
expectations.

This change pushes more of the logic for linting files into
the TestExpectations classes themselves, but it's still a bit of
a hack. A better solution will require splitting out the actual
parsing of the files from the TestExpectations constructor.

* Scripts/webkitpy/layout_tests/models/test_expectations.py:
(TestExpectations):
(TestExpectations.__init__):
* Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
(parse_exp):
(SkippedTests.check):
* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(lint):
* Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
(LintTest.test_all_configurations.FakePort.__init__):
(LintTest.test_all_configurations):
(LintTest.test_lint_test_files__errors):
* Scripts/webkitpy/style/checkers/test_expectations.py:
(TestExpectationsChecker.check_test_expectations):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (132529 => 132530)


--- trunk/Tools/ChangeLog	2012-10-25 20:50:39 UTC (rev 132529)
+++ trunk/Tools/ChangeLog	2012-10-25 20:51:26 UTC (rev 132530)
@@ -1,3 +1,33 @@
+2012-10-25  Dirk Pranke  <[email protected]>
+
+        rwt --lint-test-files doesn't handle the cascade properly
+        https://bugs.webkit.org/show_bug.cgi?id=100315
+
+        Reviewed by Ojan Vafai.
+
+        We were only linting the first file in each port's list of
+        expectations.
+
+        This change pushes more of the logic for linting files into
+        the TestExpectations classes themselves, but it's still a bit of
+        a hack. A better solution will require splitting out the actual
+        parsing of the files from the TestExpectations constructor.
+
+        * Scripts/webkitpy/layout_tests/models/test_expectations.py:
+        (TestExpectations):
+        (TestExpectations.__init__):
+        * Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
+        (parse_exp):
+        (SkippedTests.check):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        (lint):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
+        (LintTest.test_all_configurations.FakePort.__init__):
+        (LintTest.test_all_configurations):
+        (LintTest.test_lint_test_files__errors):
+        * Scripts/webkitpy/style/checkers/test_expectations.py:
+        (TestExpectationsChecker.check_test_expectations):
+
 2012-10-25  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening.

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2012-10-25 20:50:39 UTC (rev 132529)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2012-10-25 20:51:26 UTC (rev 132530)
@@ -837,16 +837,19 @@
             suffixes.add('wav')
         return set(suffixes)
 
-    def __init__(self, port, tests=None, is_lint_mode=False, include_overrides=True):
+    # FIXME: This constructor does too much work. We should move the actual parsing of
+    # the expectations into separate routines so that linting and handling overrides
+    # can be controlled separately, and the constructor can be more of a no-op.
+    def __init__(self, port, tests=None, include_overrides=True, expectations_to_lint=None):
         self._full_test_list = tests
         self._test_config = port.test_configuration()
-        self._is_lint_mode = is_lint_mode
+        self._is_lint_mode = expectations_to_lint is not None
         self._model = TestExpectationsModel(self._shorten_filename)
-        self._parser = TestExpectationParser(port, tests, is_lint_mode)
+        self._parser = TestExpectationParser(port, tests, self._is_lint_mode)
         self._port = port
         self._skipped_tests_warnings = []
 
-        expectations_dict = port.expectations_dict()
+        expectations_dict = expectations_to_lint or port.expectations_dict()
         self._expectations = self._parser.parse(expectations_dict.keys()[0], expectations_dict.values()[0])
         self._add_expectations(self._expectations)
 

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py	2012-10-25 20:50:39 UTC (rev 132529)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py	2012-10-25 20:51:26 UTC (rev 132530)
@@ -80,7 +80,8 @@
         if overrides:
             expectations_dict['overrides'] = overrides
         self._port.expectations_dict = lambda: expectations_dict
-        self._exp = TestExpectations(self._port, self.get_basic_tests(), is_lint_mode)
+        expectations_to_lint = expectations_dict if is_lint_mode else None
+        self._exp = TestExpectations(self._port, self.get_basic_tests(), expectations_to_lint=expectations_to_lint)
 
     def assert_exp(self, test, result):
         self.assertEquals(self._exp.get_expectations(self.get_test(test)),
@@ -247,7 +248,8 @@
             expectations_dict['overrides'] = overrides
         port.expectations_dict = lambda: expectations_dict
         port.skipped_layout_tests = lambda tests: set(skips)
-        exp = TestExpectations(port, ['failures/expected/text.html'], lint)
+        expectations_to_lint = expectations_dict if lint else None
+        exp = TestExpectations(port, ['failures/expected/text.html'], expectations_to_lint=expectations_to_lint)
 
         # Check that the expectation is for BUG_DUMMY SKIP : ... [ Pass ]
         self.assertEquals(exp.get_modifiers('failures/expected/text.html'),

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py (132529 => 132530)


--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2012-10-25 20:50:39 UTC (rev 132529)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2012-10-25 20:51:26 UTC (rev 132530)
@@ -67,19 +67,20 @@
     lint_failed = False
 
     for port_to_lint in ports_to_lint:
-        expectations_file = port_to_lint.path_to_test_expectations_file()
-        if expectations_file in files_linted:
-            continue
+        expectations_dict = port_to_lint.expectations_dict()
+        for expectations_file in expectations_dict.keys():
+            if expectations_file in files_linted:
+                continue
 
-        try:
-            test_expectations.TestExpectations(port_to_lint, is_lint_mode=True)
-        except test_expectations.ParseError, e:
-            lint_failed = True
-            _log.error('')
-            for warning in e.warnings:
-                _log.error(warning)
-            _log.error('')
-        files_linted.add(expectations_file)
+            try:
+                test_expectations.TestExpectations(port_to_lint, expectations_to_lint={expectations_file: expectations_dict[expectations_file]})
+            except test_expectations.ParseError, e:
+                lint_failed = True
+                _log.error('')
+                for warning in e.warnings:
+                    _log.error(warning)
+                _log.error('')
+            files_linted.add(expectations_file)
 
     if lint_failed:
         _log.error('Lint failed.')

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py (132529 => 132530)


--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py	2012-10-25 20:50:39 UTC (rev 132529)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py	2012-10-25 20:51:26 UTC (rev 132530)
@@ -199,9 +199,6 @@
                 self.name = name
                 self.path = path
 
-            def path_to_test_expectations_file(self):
-                return self.path
-
             def test_configuration(self):
                 return None
 
@@ -244,7 +241,7 @@
                                                FakePort(host, 'b-win', 'path-to-b')))
 
         self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform=None)), 0)
-        self.assertEquals(host.ports_parsed, ['a', 'b'])
+        self.assertEquals(host.ports_parsed, ['a', 'b', 'b-win'])
 
         host.ports_parsed = []
         self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform='a')), 0)
@@ -267,7 +264,16 @@
         self.assertEmpty(out)
         self.assertTrue(any(['Lint failed' in msg for msg in err.buflist]))
 
+        # ensure we lint *all* of the files in the cascade.
+        port_obj.expectations_dict = lambda: {'foo': '-- syntax error1', 'bar': '-- syntax error2'}
+        res, out, err = run_and_capture(port_obj, options, parsed_args)
 
+        self.assertEqual(res, -1)
+        self.assertEmpty(out)
+        self.assertTrue(any(['foo:1' in msg for msg in err.buflist]))
+        self.assertTrue(any(['bar:1' in msg for msg in err.buflist]))
+
+
 class MainTest(unittest.TestCase, StreamTestingMixin):
     def setUp(self):
         # A real PlatformInfo object is used here instead of a

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py (132529 => 132530)


--- trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py	2012-10-25 20:50:39 UTC (rev 132529)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py	2012-10-25 20:51:26 UTC (rev 132530)
@@ -79,7 +79,7 @@
         pass
 
     def check_test_expectations(self, expectations_str, tests=None):
-        parser = TestExpectationParser(self._port_obj, tests, False)
+        parser = TestExpectationParser(self._port_obj, tests, allow_rebaseline_modifier=False)
         expectations = parser.parse('expectations', expectations_str)
 
         level = 5
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to