⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 117805 in webkit


Ignore:
Timestamp:
May 21, 2012, 11:52:16 AM (14 years ago)
Author:
dpranke@chromium.org
Message:

webkitpy: clean up the TestExpectations constructor
https://bugs.webkit.org/show_bug.cgi?id=86926

Reviewed by Ojan Vafai.

The TestExpectations constructor was attempting to pretend
it didn't need to get stuff from the Port, and as a result we
had a complicated constructor with a bunch of arguments, and
calling it was too complicated (although it made testing a
little easier and simplified the style checker).

This patch has the constructor pull all the data it needs from
the port directly, and allows us to delete a bunch of code.

  • Scripts/webkitpy/layout_tests/controllers/manager.py:

(Manager.parse_expectations):

  • Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:

(ManagerTest.test_update_summary_with_result):
(ResultSummaryTest.get_result_summary):

  • Scripts/webkitpy/layout_tests/models/test_expectations.py:

(TestExpectations.init):

  • Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:

(parse_exp):
(SkippedTests.check):
(RemoveConfigurationsTest.test_remove):
(test_remove_line):

  • Scripts/webkitpy/layout_tests/run_webkit_tests.py:

(lint):
(run):

  • Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:

(LintTest.test_all_configurations.FakePort.init):
(LintTest.test_all_configurations.FakePort.test_expectations):
(LintTest.test_all_configurations.FakePort.skipped_layout_tests):
(LintTest.test_all_configurations.FakePort):
(LintTest.test_all_configurations.FakePort.all_test_configurations):
(LintTest.test_all_configurations.FakePort.configuration_specifier_macros):
(LintTest.test_all_configurations.FakePort.path_from_webkit_base):
(LintTest.test_all_configurations.FakePort.get_option):
(LintTest.test_all_configurations.FakeFactory.init):
(LintTest.test_all_configurations.FakeFactory.all_port_names):
(LintTest.test_all_configurations):

  • Scripts/webkitpy/layout_tests/views/printing_unittest.py:

(Testprinter.get_result_summary):

  • Scripts/webkitpy/style/checkers/test_expectations.py:

(TestExpectationsChecker.check_test_expectations):

  • Scripts/webkitpy/tool/commands/queries.py:

(PrintExpectations._model):

  • Scripts/webkitpy/tool/commands/rebaseline.py:

(RebaselineTest._update_expectations_file):
(RebaselineExpectations._expectations):

Location:
trunk/Tools
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r117804 r117805  
     12012-05-21  Dirk Pranke  <dpranke@chromium.org>
     2
     3        webkitpy: clean up the TestExpectations constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=86926
     5
     6        Reviewed by Ojan Vafai.
     7
     8        The TestExpectations constructor was attempting to pretend
     9        it didn't need to get stuff from the Port, and as a result we
     10        had a complicated constructor with a bunch of arguments, and
     11        calling it was too complicated (although it made testing a
     12        little easier and simplified the style checker).
     13
     14        This patch has the constructor pull all the data it needs from
     15        the port directly, and allows us to delete a bunch of code.
     16
     17        * Scripts/webkitpy/layout_tests/controllers/manager.py:
     18        (Manager.parse_expectations):
     19        * Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
     20        (ManagerTest.test_update_summary_with_result):
     21        (ResultSummaryTest.get_result_summary):
     22        * Scripts/webkitpy/layout_tests/models/test_expectations.py:
     23        (TestExpectations.__init__):
     24        * Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
     25        (parse_exp):
     26        (SkippedTests.check):
     27        (RemoveConfigurationsTest.test_remove):
     28        (test_remove_line):
     29        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
     30        (lint):
     31        (run):
     32        * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
     33        (LintTest.test_all_configurations.FakePort.__init__):
     34        (LintTest.test_all_configurations.FakePort.test_expectations):
     35        (LintTest.test_all_configurations.FakePort.skipped_layout_tests):
     36        (LintTest.test_all_configurations.FakePort):
     37        (LintTest.test_all_configurations.FakePort.all_test_configurations):
     38        (LintTest.test_all_configurations.FakePort.configuration_specifier_macros):
     39        (LintTest.test_all_configurations.FakePort.path_from_webkit_base):
     40        (LintTest.test_all_configurations.FakePort.get_option):
     41        (LintTest.test_all_configurations.FakeFactory.__init__):
     42        (LintTest.test_all_configurations.FakeFactory.all_port_names):
     43        (LintTest.test_all_configurations):
     44        * Scripts/webkitpy/layout_tests/views/printing_unittest.py:
     45        (Testprinter.get_result_summary):
     46        * Scripts/webkitpy/style/checkers/test_expectations.py:
     47        (TestExpectationsChecker.check_test_expectations):
     48        * Scripts/webkitpy/tool/commands/queries.py:
     49        (PrintExpectations._model):
     50        * Scripts/webkitpy/tool/commands/rebaseline.py:
     51        (RebaselineTest._update_expectations_file):
     52        (RebaselineExpectations._expectations):
     53
    1542012-05-21  Sudarsana Nagineni  <sudarsana.nagineni@linux.intel.com>
    255
  • trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py

    r116552 r117805  
    363363
    364364    def parse_expectations(self):
    365         """Parse the expectations from the test_list files and return a data
    366         structure holding them. Throws an error if the test_list files have
    367         invalid syntax."""
    368         port = self._port
    369         tests_to_ignore = set(self._options.ignore_tests)
    370         self._expectations = test_expectations.TestExpectations(
    371             port,
    372             self._test_files,
    373             port.test_expectations(),
    374             port.test_configuration(),
    375             self._options.lint_test_files,
    376             port.test_expectations_overrides(),
    377             port.skipped_layout_tests(self._test_files).union(tests_to_ignore))
     365        self._expectations = test_expectations.TestExpectations(self._port, self._test_files)
    378366
    379367    def _split_into_chunks_if_necessary(self, skipped):
  • trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py

    r112805 r117805  
    258258        port = host.port_factory.get('test-win-xp')
    259259        test = 'failures/expected/reftest.html'
    260         expectations = TestExpectations(port, tests=[test],
    261              expectations='WONTFIX : failures/expected/reftest.html = IMAGE',
    262              test_config=port.test_configuration())
     260        port.test_expectations = lambda: 'WONTFIX : failures/expected/reftest.html = IMAGE'
     261        expectations = TestExpectations(port, tests=[test])
    263262        # Reftests expected to be image mismatch should be respected when pixel_tests=False.
    264263        manager = Manager(port=port, options=MockOptions(pixel_tests=False, exit_after_n_failures=None, exit_after_n_crashes_or_timeouts=None), printer=Mock())
     
    386385
    387386    def get_result_summary(self, port, test_names, expectations_str):
    388         expectations = test_expectations.TestExpectations(port, test_names, expectations_str, port.test_configuration(), is_lint_mode=False)
     387        port.test_expectations = lambda: expectations_str
     388        expectations = test_expectations.TestExpectations(port, test_names)
    389389        return test_names, result_summary.ResultSummary(expectations, test_names), expectations
    390390
  • trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py

    r113802 r117805  
    723723        return cls.EXPECTATIONS.get(string.lower())
    724724
    725     def __init__(self, port, tests, expectations,
    726                  test_config, is_lint_mode=False, overrides=None,
    727                  skipped_tests=None):
    728         """Loads and parses the test expectations given in the string.
    729         Args:
    730             port: handle to object containing platform-specific functionality
    731             tests: list of all of the test files
    732             expectations: test expectations as a string
    733             test_config: specific values to check against when
    734                 parsing the file (usually port.test_config(),
    735                 but may be different when linting or doing other things).
    736             is_lint_mode: If True, parse the expectations string and raise
    737                 an exception if warnings are encountered.
    738             overrides: test expectations that are allowed to override any
    739                 entries in |expectations|. This is used by callers
    740                 that need to manage two sets of expectations (e.g., upstream
    741                 and downstream expectations).
    742             skipped_tests: test paths to skip.
    743         """
     725    def __init__(self, port, tests=None, is_lint_mode=False):
    744726        self._full_test_list = tests
    745         self._test_config = test_config
     727        self._test_config = port.test_configuration()
    746728        self._is_lint_mode = is_lint_mode
    747729        self._model = TestExpectationsModel()
     
    750732        self._skipped_tests_warnings = []
    751733
    752         self._expectations = self._parser.parse(expectations)
     734        self._expectations = self._parser.parse(port.test_expectations())
    753735        self._add_expectations(self._expectations, in_overrides=False)
    754736
     737        overrides = port.test_expectations_overrides()
    755738        if overrides:
    756739            overrides_expectations = self._parser.parse(overrides)
     
    758741            self._expectations += overrides_expectations
    759742
    760         self._add_skipped_tests(skipped_tests or [])
     743        # FIXME: move ignore_tests into port.skipped_layout_tests()
     744        self._add_skipped_tests(port.skipped_layout_tests(tests).union(set(port.get_option('ignore_tests', []))))
    761745
    762746        self._has_warnings = False
  • trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py

    r111261 r117805  
    120120
    121121    def parse_exp(self, expectations, overrides=None, is_lint_mode=False):
    122         test_config = self._port.test_configuration()
    123         self._exp = TestExpectations(self._port,
    124              tests=self.get_basic_tests(),
    125              expectations=expectations,
    126              test_config=test_config,
    127              is_lint_mode=is_lint_mode,
    128              overrides=overrides)
     122        self._port.test_expectations = lambda: expectations
     123        self._port.test_expectations_overrides = lambda: overrides
     124        self._exp = TestExpectations(self._port, self.get_basic_tests(), is_lint_mode)
    129125
    130126    def assert_exp(self, test, result):
     
    266262        port = MockHost().port_factory.get('qt')
    267263        port._filesystem.write_text_file(port._filesystem.join(port.layout_tests_dir(), 'failures/expected/text.html'), 'foo')
    268         exp = TestExpectations(port, tests=['failures/expected/text.html'],
    269                                expectations=expectations, overrides=overrides, is_lint_mode=lint,
    270                                test_config=port.test_configuration(), skipped_tests=set(skips))
     264        port.test_expectations = lambda: expectations
     265        port.test_expectations_overrides = lambda: overrides
     266        port.skipped_layout_tests = lambda tests: set(skips)
     267        exp = TestExpectations(port, ['failures/expected/text.html'], lint)
    271268
    272269        # Check that the expectation is for BUG_DUMMY SKIP : ... = PASS
     
    411408
    412409        test_config = test_port.test_configuration()
    413         expectations = TestExpectations(test_port,
    414              tests=self.get_basic_tests(),
    415              expectations="""BUGX LINUX WIN RELEASE : failures/expected/foo.html = TEXT
     410        test_port.test_expectations = lambda: """BUGX LINUX WIN RELEASE : failures/expected/foo.html = TEXT
    416411BUGY WIN MAC DEBUG : failures/expected/foo.html = CRASH
    417 """,
    418              test_config=test_config,
    419              is_lint_mode=False,
    420              overrides=None)
     412"""
     413        expectations = TestExpectations(test_port, self.get_basic_tests())
    421414
    422415        actual_expectations = expectations.remove_configuration_from_test('failures/expected/foo.html', test_config)
     
    433426
    434427        test_config = test_port.test_configuration()
    435         expectations = TestExpectations(test_port,
    436              tests=None,
    437              expectations="""BUGX WIN RELEASE : failures/expected/foo.html = TEXT
     428        test_port.test_expectations = lambda: """BUGX WIN RELEASE : failures/expected/foo.html = TEXT
    438429BUGY WIN DEBUG : failures/expected/foo.html = CRASH
    439 """,
    440              test_config=test_config,
    441              is_lint_mode=False,
    442              overrides=None)
     430"""
     431        expectations = TestExpectations(test_port)
    443432
    444433        actual_expectations = expectations.remove_configuration_from_test('failures/expected/foo.html', test_config)
  • trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py

    r116859 r117805  
    4747
    4848
    49 def lint(port, options, expectations_class):
     49def lint(port, options):
    5050    host = port.host
    5151    if options.platform:
     
    6363
    6464        try:
    65             expectations_class(port_to_lint,
    66                 tests=None,
    67                 expectations=port_to_lint.test_expectations(),
    68                 test_config=port_to_lint.test_configuration(),
    69                 is_lint_mode=True,
    70                 overrides=port_to_lint.test_expectations_overrides())
     65            test_expectations.TestExpectations(port_to_lint, is_lint_mode=True)
    7166        except test_expectations.ParseError, e:
    7267            lint_failed = True
     
    9893
    9994    if options.lint_test_files:
    100         return lint(port, options, test_expectations.TestExpectations)
     95        return lint(port, options)
    10196
    10297    # We wrap any parts of the run that are slow or likely to raise exceptions
  • trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py

    r116552 r117805  
    193193
    194194        class FakePort(object):
    195             def __init__(self, name, path):
     195            def __init__(self, host, name, path):
     196                self.host = host
    196197                self.name = name
    197198                self.path = path
    198199
    199200            def test_expectations(self):
     201                self.host.ports_parsed.append(self.name)
    200202                return ''
    201203
     
    208210            def test_expectations_overrides(self):
    209211                return None
     212
     213            def skipped_layout_tests(self, tests):
     214                return set([])
     215
     216            def all_test_configurations(self):
     217                return []
     218
     219            def configuration_specifier_macros(self):
     220                return []
     221
     222            def path_from_webkit_base(self):
     223                return ''
     224
     225            def get_option(self, name, val):
     226                return val
    210227
    211228        class FakeFactory(object):
     
    215232                for port in ports:
    216233                    self.ports[port.name] = port
    217                     port.host = host
    218                     port.factory = self
    219234
    220235            def get(self, port_name, *args, **kwargs):
     
    224239                return sorted(self.ports.keys())
    225240
    226         class FakeExpectationsParser(object):
    227             def __init__(self, port, *args, **kwargs):
    228                 port.host.ports_parsed.append(port.name)
    229 
    230241        host = MockHost()
    231242        host.ports_parsed = []
    232         host.port_factory = FakeFactory(host, (FakePort('a', 'path-to-a'),
    233                                                FakePort('b', 'path-to-b'),
    234                                                FakePort('b-win', 'path-to-b')))
    235 
    236         self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform=None), FakeExpectationsParser), 0)
     243        host.port_factory = FakeFactory(host, (FakePort(host, 'a', 'path-to-a'),
     244                                               FakePort(host, 'b', 'path-to-b'),
     245                                               FakePort(host, 'b-win', 'path-to-b')))
     246
     247        self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform=None)), 0)
    237248        self.assertEquals(host.ports_parsed, ['a', 'b'])
    238249
    239250        host.ports_parsed = []
    240         self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform='a'), FakeExpectationsParser), 0)
     251        self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform='a')), 0)
    241252        self.assertEquals(host.ports_parsed, ['a'])
    242253
  • trunk/Tools/Scripts/webkitpy/layout_tests/views/printing_unittest.py

    r112140 r117805  
    127127
    128128    def get_result_summary(self, test_names, expectations_str):
    129         expectations = test_expectations.TestExpectations(
    130             self._port, test_names, expectations_str,
    131             self._port.test_configuration(),
    132             is_lint_mode=False)
     129        port.test_expectations = lambda: expectations_str
     130        port.test_expectations_overrides = lambda: None
     131        expectations = test_expectations.TestExpectations(self._port, test_names)
    133132
    134133        rs = result_summary.ResultSummary(expectations, test_names)
  • trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py

    r107124 r117805  
    8080        err = None
    8181        expectations = None
     82        # FIXME: We need to rework how we lint strings so that we can do it independently of what a
     83        # port's existing expectations are. Linting should probably just call the parser directly.
     84        # For now we override the port hooks. This will also need to be reworked when expectations
     85        # can cascade arbitrarily, rather than just have expectations and overrides.
     86        orig_expectations = self._port_obj.test_expectations
     87        orig_overrides = self._port_obj.test_expectations_overrides
    8288        try:
    83             expectations = test_expectations.TestExpectations(
    84                 port=self._port_obj, expectations=expectations_str, tests=tests,
    85                 test_config=self._port_obj.test_configuration(),
    86                 is_lint_mode=True, overrides=overrides)
     89            self._port_obj.test_expectations = lambda: expectations_str
     90            self._port_obj.test_expectations_overrides = lambda: overrides
     91            expectations = test_expectations.TestExpectations(self._port_obj, tests, True)
    8792        except test_expectations.ParseError, error:
    8893            err = error
     94        finally:
     95            self._port_obj.text_expectations = orig_expectations
     96            self._port_obj.text_expectations_overrides = orig_overrides
    8997
    9098        if err:
  • trunk/Tools/Scripts/webkitpy/tool/commands/queries.py

    r115977 r117805  
    457457        expectations_path = port.path_to_test_expectations_file()
    458458        if not expectations_path in self._expectation_models:
    459             lint_mode = False
    460             self._expectation_models[expectations_path] = TestExpectations(port, tests,
    461                 port.test_expectations(),
    462                 port.test_configuration(),
    463                 lint_mode,
    464                 port.test_expectations_overrides(),
    465                 port.skipped_layout_tests(tests)).model()
     459            self._expectation_models[expectations_path] = TestExpectations(port, tests).model()
    466460        return self._expectation_models[expectations_path]
    467461
  • trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py

    r116988 r117805  
    122122    def _update_expectations_file(self, builder_name, test_name):
    123123        port = self._tool.port_factory.get_from_builder_name(builder_name)
    124         expectationsString = port.test_expectations()
    125         expectations = TestExpectations(port, None, expectationsString, port.test_configuration())
     124        expectations = TestExpectations(port)
    126125
    127126        for test_configuration in port.all_test_configurations():
     
    240239
    241240    def _expectations(self, port):
    242         return TestExpectations(port, None, port.test_expectations(), port.test_configuration())
     241        return TestExpectations(port)
    243242
    244243    def _update_expectations_file(self, port_name):
Note: See TracChangeset for help on using the changeset viewer.