Move expectation parsing out of the constructor of TestExpectations
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Dec 2013 11:41:08 +0000 (11:41 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Dec 2013 11:41:08 +0000 (11:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125439

Patch by Dániel Bátyai <Batyai.Daniel@stud.u-szeged.hu> on 2013-12-18
Reviewed by Csaba Osztrogonác.

* Scripts/webkitpy/layout_tests/controllers/layout_test_runner_unittest.py:
(LayoutTestRunnerTests._run_tests):
(LayoutTestRunnerTests.test_interrupt_if_at_failure_limits):
(LayoutTestRunnerTests.test_update_summary_with_result):
* Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager.run):
* Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
(ManagerTest.test_look_for_new_crash_logs):
* Scripts/webkitpy/layout_tests/lint_test_expectations.py:
(lint):
* Scripts/webkitpy/layout_tests/models/test_expectations.py:
(TestExpectations.suffixes_for_expectations):
(TestExpectations.__init__):
(TestExpectations):
(TestExpectations.parse_generic_expectations):
(TestExpectations.parse_default_port_expectations):
(TestExpectations.parse_override_expectations):
(TestExpectations.parse_all_expectations):
* Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
(parse_exp):
(SkippedTests.check):
(SkippedTests.test_skipped_entry_dont_exist):
* Scripts/webkitpy/layout_tests/models/test_run_results_unittest.py:
(run_results):
* Scripts/webkitpy/tool/commands/queries.py:
(PrintExpectations._model):
* Scripts/webkitpy/tool/commands/rebaseline.py:
(RebaselineTest._update_expectations_file):
(RebaselineExpectations._update_expectations_files):
(RebaselineExpectations._tests_to_rebaseline):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_runner_unittest.py
Tools/Scripts/webkitpy/layout_tests/controllers/manager.py
Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py
Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py
Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py
Tools/Scripts/webkitpy/layout_tests/models/test_run_results_unittest.py
Tools/Scripts/webkitpy/tool/commands/queries.py
Tools/Scripts/webkitpy/tool/commands/rebaseline.py

index c9673fd..6b71e91 100644 (file)
@@ -1,3 +1,41 @@
+2013-12-18  Dániel Bátyai  <Batyai.Daniel@stud.u-szeged.hu>
+
+        Move expectation parsing out of the constructor of TestExpectations
+        https://bugs.webkit.org/show_bug.cgi?id=125439
+
+        Reviewed by Csaba Osztrogonác.
+
+        * Scripts/webkitpy/layout_tests/controllers/layout_test_runner_unittest.py:
+        (LayoutTestRunnerTests._run_tests):
+        (LayoutTestRunnerTests.test_interrupt_if_at_failure_limits):
+        (LayoutTestRunnerTests.test_update_summary_with_result):
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        (Manager.run):
+        * Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
+        (ManagerTest.test_look_for_new_crash_logs):
+        * Scripts/webkitpy/layout_tests/lint_test_expectations.py:
+        (lint):
+        * Scripts/webkitpy/layout_tests/models/test_expectations.py:
+        (TestExpectations.suffixes_for_expectations):
+        (TestExpectations.__init__):
+        (TestExpectations):
+        (TestExpectations.parse_generic_expectations):
+        (TestExpectations.parse_default_port_expectations):
+        (TestExpectations.parse_override_expectations):
+        (TestExpectations.parse_all_expectations):
+        * Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
+        (parse_exp):
+        (SkippedTests.check):
+        (SkippedTests.test_skipped_entry_dont_exist):
+        * Scripts/webkitpy/layout_tests/models/test_run_results_unittest.py:
+        (run_results):
+        * Scripts/webkitpy/tool/commands/queries.py:
+        (PrintExpectations._model):
+        * Scripts/webkitpy/tool/commands/rebaseline.py:
+        (RebaselineTest._update_expectations_file):
+        (RebaselineExpectations._update_expectations_files):
+        (RebaselineExpectations._tests_to_rebaseline):
+
 2013-12-17  Jer Noble  <jer.noble@apple.com>
 
         Fix TimeRanges::intersectWith
index 406870a..80977e5 100644 (file)
@@ -104,6 +104,7 @@ class LayoutTestRunnerTests(unittest.TestCase):
     def _run_tests(self, runner, tests):
         test_inputs = [TestInput(test, 6000) for test in tests]
         expectations = TestExpectations(runner._port, tests)
+        expectations.parse_all_expectations()
         runner.run_tests(expectations, test_inputs, set(),
             num_workers=1, needs_http=any('http' in test for test in tests), needs_websockets=any(['websocket' in test for test in tests]), retrying=False)
 
@@ -122,7 +123,9 @@ class LayoutTestRunnerTests(unittest.TestCase):
         test_names = ['passes/text.html', 'passes/image.html']
         runner._test_inputs = [TestInput(test_name, 6000) for test_name in test_names]
 
-        run_results = TestRunResults(TestExpectations(runner._port, test_names), len(test_names))
+        expectations = TestExpectations(runner._port, test_names)
+        expectations.parse_all_expectations()
+        run_results = TestRunResults(expectations, len(test_names))
         run_results.unexpected_failures = 100
         run_results.unexpected_crashes = 50
         run_results.unexpected_timeouts = 50
@@ -150,6 +153,7 @@ class LayoutTestRunnerTests(unittest.TestCase):
         runner._options.pixel_tests = False
         test = 'failures/expected/reftest.html'
         expectations = TestExpectations(runner._port, tests=[test])
+        expectations.parse_all_expectations()
         runner._expectations = expectations
 
         run_results = TestRunResults(expectations, 1)
index 7370d58..4ab32e5 100644 (file)
@@ -182,6 +182,7 @@ class Manager(object):
 
         self._printer.write_update("Parsing expectations ...")
         self._expectations = test_expectations.TestExpectations(self._port, test_names, force_expectations_pass=self._options.force)
+        self._expectations.parse_all_expectations()
 
         tests_to_run, tests_to_skip = self._prepare_lists(paths, test_names)
         self._printer.print_found(len(test_names), len(tests_to_run), self._options.repeat_each, self._options.iterations)
index 4a81548..3aefc3d 100644 (file)
@@ -85,6 +85,7 @@ class ManagerTest(unittest.TestCase):
         port = host.port_factory.get('test-mac-leopard')
         tests = ['failures/expected/crash.html']
         expectations = test_expectations.TestExpectations(port, tests)
+        expectations.parse_all_expectations()
         run_results = TestRunResults(expectations, len(tests))
         manager = get_manager()
         manager._look_for_new_crash_logs(run_results, time.time())
index 90e4cbb..5fe8024 100644 (file)
@@ -66,8 +66,9 @@ def lint(host, options, logging_stream):
                     continue
 
                 try:
-                    test_expectations.TestExpectations(port_to_lint,
+                    expectations = test_expectations.TestExpectations(port_to_lint,
                         expectations_to_lint={expectations_file: expectations_dict[expectations_file]})
+                    expectations.parse_all_expectations()
                 except test_expectations.ParseError as e:
                     lint_failed = True
                     _log.error('')
index c84247d..4476cab 100644 (file)
@@ -830,9 +830,6 @@ class TestExpectations(object):
             suffixes.add('wav')
         return set(suffixes)
 
-    # 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_generic=True, include_overrides=True, expectations_to_lint=None, force_expectations_pass=False):
         self._full_test_list = tests
         self._test_config = port.test_configuration()
@@ -843,36 +840,45 @@ class TestExpectations(object):
         self._skipped_tests_warnings = []
         self._expectations = []
         self._force_expectations_pass = force_expectations_pass
-
-        expectations_dict = expectations_to_lint or port.expectations_dict()
-
-        expectations_dict_index = 0
-        # Populate generic expectations (if enabled by include_generic).
-        if port.path_to_generic_test_expectations_file() in expectations_dict:
-            if include_generic:
-                expectations = self._parser.parse(expectations_dict.keys()[expectations_dict_index], expectations_dict.values()[expectations_dict_index])
+        self._include_generic = include_generic
+        self._include_overrides = include_overrides
+        self._expectations_to_lint = expectations_to_lint
+
+    def parse_generic_expectations(self):
+        if self._port.path_to_generic_test_expectations_file() in self._expectations_dict:
+            if self._include_generic:
+                expectations = self._parser.parse(self._expectations_dict.keys()[self._expectations_dict_index], self._expectations_dict.values()[self._expectations_dict_index])
                 self._add_expectations(expectations)
                 self._expectations += expectations
-            expectations_dict_index += 1
+            self._expectations_dict_index += 1
 
-        # Populate default port expectations (always enabled).
-        if len(expectations_dict) > expectations_dict_index:
-            expectations = self._parser.parse(expectations_dict.keys()[expectations_dict_index], expectations_dict.values()[expectations_dict_index])
+    def parse_default_port_expectations(self):
+        if len(self._expectations_dict) > self._expectations_dict_index:
+            expectations = self._parser.parse(self._expectations_dict.keys()[self._expectations_dict_index], self._expectations_dict.values()[self._expectations_dict_index])
             self._add_expectations(expectations)
             self._expectations += expectations
-            expectations_dict_index += 1
+            self._expectations_dict_index += 1
 
-        # Populate override expectations (if enabled by include_overrides).
-        while len(expectations_dict) > expectations_dict_index and include_overrides:
-            expectations = self._parser.parse(expectations_dict.keys()[expectations_dict_index], expectations_dict.values()[expectations_dict_index])
+    def parse_override_expectations(self):
+        while len(self._expectations_dict) > self._expectations_dict_index and self._include_overrides:
+            expectations = self._parser.parse(self._expectations_dict.keys()[self._expectations_dict_index], self._expectations_dict.values()[self._expectations_dict_index])
             self._add_expectations(expectations)
             self._expectations += expectations
-            expectations_dict_index += 1
+            self._expectations_dict_index += 1
 
-        # FIXME: move ignore_tests into port.skipped_layout_tests()
-        self.add_skipped_tests(port.skipped_layout_tests(tests).union(set(port.get_option('ignore_tests', []))))
+    def parse_all_expectations(self):
+        self._expectations_dict = self._expectations_to_lint or self._port.expectations_dict()
+        self._expectations_dict_index = 0
 
         self._has_warnings = False
+
+        self.parse_generic_expectations()
+        self.parse_default_port_expectations()
+        self.parse_override_expectations()
+
+        # FIXME: move ignore_tests into port.skipped_layout_tests()
+        self.add_skipped_tests(self._port.skipped_layout_tests(self._full_test_list).union(set(self._port.get_option('ignore_tests', []))))
+
         self._report_warnings()
         self._process_tests_without_expectations()
 
index 0b1f615..f6549b6 100644 (file)
@@ -78,6 +78,7 @@ Bug(test) failures/expected/image.html [ WontFix Mac ]
         self._port.expectations_dict = lambda: expectations_dict
         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)
+        self._exp.parse_all_expectations()
 
     def assert_exp(self, test, result):
         self.assertEqual(self._exp.model().get_expectations(test),
@@ -251,6 +252,7 @@ class SkippedTests(Base):
         port.skipped_layout_tests = lambda tests: set(skips)
         expectations_to_lint = expectations_dict if lint else None
         exp = TestExpectations(port, ['failures/expected/text.html'], expectations_to_lint=expectations_to_lint)
+        exp.parse_all_expectations()
 
         # Check that the expectation is for BUG_DUMMY SKIP : ... [ Pass ]
         self.assertEqual(exp.model().get_modifiers('failures/expected/text.html'),
@@ -288,6 +290,7 @@ class SkippedTests(Base):
         capture = OutputCapture()
         capture.capture_output()
         exp = TestExpectations(port)
+        exp.parse_all_expectations()
         _, _, logs = capture.restore_output()
         self.assertEqual('The following test foo/bar/baz.html from the Skipped list doesn\'t exist\n', logs)
 
@@ -471,6 +474,7 @@ class RemoveConfigurationsTest(Base):
 Bug(y) [ Win Mac Debug ] failures/expected/foo.html [ Crash ]
 """}
         expectations = TestExpectations(test_port, self.get_basic_tests())
+        expectations.parse_all_expectations()
 
         actual_expectations = expectations.remove_configuration_from_test('failures/expected/foo.html', test_config)
 
@@ -489,6 +493,7 @@ Bug(y) [ Win Mac Debug ] failures/expected/foo.html [ Crash ]
 Bug(y) [ Win Debug ] failures/expected/foo.html [ Crash ]
 """}
         expectations = TestExpectations(test_port)
+        expectations.parse_all_expectations()
 
         actual_expectations = expectations.remove_configuration_from_test('failures/expected/foo.html', test_config)
         actual_expectations = expectations.remove_configuration_from_test('failures/expected/foo.html', host.port_factory.get('test-win-vista', None).test_configuration())
index a985bdf..0a7ca2f 100644 (file)
@@ -50,6 +50,7 @@ def run_results(port):
     tests = ['passes/text.html', 'failures/expected/timeout.html', 'failures/expected/crash.html', 'failures/expected/hang.html',
              'failures/expected/audio.html']
     expectations = test_expectations.TestExpectations(port, tests)
+    expectations.parse_all_expectations()
     return test_run_results.TestRunResults(expectations, len(tests))
 
 
index 202f607..24353d1 100644 (file)
@@ -524,7 +524,9 @@ class PrintExpectations(Command):
 
     def _model(self, options, port_name, tests):
         port = self._tool.port_factory.get(port_name, options)
-        return TestExpectations(port, tests).model()
+        expectations = TestExpectations(port, tests)
+        expectations.parse_all_expectations()
+        return expectations.model()
 
 
 class PrintBaselines(Command):
index eb91dc4..d13aeef 100644 (file)
@@ -152,6 +152,7 @@ class RebaselineTest(AbstractRebaseliningCommand):
             lock = self._tool.make_file_lock(path + '.lock')
             lock.acquire_lock()
             expectations = TestExpectations(port, include_generic=False, include_overrides=False)
+            expectations.parse_all_expectations()
             for test_configuration in port.all_test_configurations():
                 if test_configuration.version == port.test_configuration().version:
                     expectationsString = expectations.remove_configuration_from_test(test_name, test_configuration)
@@ -316,6 +317,7 @@ class RebaselineExpectations(AbstractParallelRebaselineCommand):
         port = self._tool.port_factory.get(port_name)
 
         expectations = TestExpectations(port)
+        expectations.parse_all_expectations()
         for path in port.expectations_dict():
             if self._tool.filesystem.exists(path):
                 self._tool.filesystem.write_text_file(path, expectations.remove_rebaselined_tests(expectations.get_rebaselining_failures(), path))
@@ -323,6 +325,7 @@ class RebaselineExpectations(AbstractParallelRebaselineCommand):
     def _tests_to_rebaseline(self, port):
         tests_to_rebaseline = {}
         expectations = TestExpectations(port, include_overrides=True)
+        expectations.parse_all_expectations()
         for test in expectations.get_rebaselining_failures():
             tests_to_rebaseline[test] = TestExpectations.suffixes_for_expectations(expectations.model().get_expectations(test))
         return tests_to_rebaseline