Diff
Modified: trunk/Tools/ChangeLog (117804 => 117805)
--- trunk/Tools/ChangeLog 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/ChangeLog 2012-05-21 18:52:16 UTC (rev 117805)
@@ -1,3 +1,56 @@
+2012-05-21 Dirk Pranke <[email protected]>
+
+ 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):
+
2012-05-21 Sudarsana Nagineni <[email protected]>
[GTK] DRT support for layoutTestController.setSerializeHTTPLoads
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (117804 => 117805)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py 2012-05-21 18:52:16 UTC (rev 117805)
@@ -362,19 +362,7 @@
return self.PERF_SUBDIR == test or (self.PERF_SUBDIR + self._port.TEST_PATH_SEPARATOR) in test
def parse_expectations(self):
- """Parse the expectations from the test_list files and return a data
- structure holding them. Throws an error if the test_list files have
- invalid syntax."""
- port = self._port
- tests_to_ignore = set(self._options.ignore_tests)
- self._expectations = test_expectations.TestExpectations(
- port,
- self._test_files,
- port.test_expectations(),
- port.test_configuration(),
- self._options.lint_test_files,
- port.test_expectations_overrides(),
- port.skipped_layout_tests(self._test_files).union(tests_to_ignore))
+ self._expectations = test_expectations.TestExpectations(self._port, self._test_files)
def _split_into_chunks_if_necessary(self, skipped):
if not self._options.run_chunk and not self._options.run_part:
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py (117804 => 117805)
--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py 2012-05-21 18:52:16 UTC (rev 117805)
@@ -257,9 +257,8 @@
host = MockHost()
port = host.port_factory.get('test-win-xp')
test = 'failures/expected/reftest.html'
- expectations = TestExpectations(port, tests=[test],
- expectations='WONTFIX : failures/expected/reftest.html = IMAGE',
- test_config=port.test_configuration())
+ port.test_expectations = lambda: 'WONTFIX : failures/expected/reftest.html = IMAGE'
+ expectations = TestExpectations(port, tests=[test])
# Reftests expected to be image mismatch should be respected when pixel_tests=False.
manager = Manager(port=port, options=MockOptions(pixel_tests=False, exit_after_n_failures=None, exit_after_n_crashes_or_timeouts=None), printer=Mock())
manager._expectations = expectations
@@ -385,7 +384,8 @@
return test_results.TestResult(test_name, failures=failures, test_run_time=run_time)
def get_result_summary(self, port, test_names, expectations_str):
- expectations = test_expectations.TestExpectations(port, test_names, expectations_str, port.test_configuration(), is_lint_mode=False)
+ port.test_expectations = lambda: expectations_str
+ expectations = test_expectations.TestExpectations(port, test_names)
return test_names, result_summary.ResultSummary(expectations, test_names), expectations
# FIXME: Use this to test more of summarize_results. This was moved from printing_unittest.py.
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py (117804 => 117805)
--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py 2012-05-21 18:52:16 UTC (rev 117805)
@@ -722,42 +722,26 @@
assert(' ' not in string) # This only handles one expectation at a time.
return cls.EXPECTATIONS.get(string.lower())
- def __init__(self, port, tests, expectations,
- test_config, is_lint_mode=False, overrides=None,
- skipped_tests=None):
- """Loads and parses the test expectations given in the string.
- Args:
- port: handle to object containing platform-specific functionality
- tests: list of all of the test files
- expectations: test expectations as a string
- test_config: specific values to check against when
- parsing the file (usually port.test_config(),
- but may be different when linting or doing other things).
- is_lint_mode: If True, parse the expectations string and raise
- an exception if warnings are encountered.
- overrides: test expectations that are allowed to override any
- entries in |expectations|. This is used by callers
- that need to manage two sets of expectations (e.g., upstream
- and downstream expectations).
- skipped_tests: test paths to skip.
- """
+ def __init__(self, port, tests=None, is_lint_mode=False):
self._full_test_list = tests
- self._test_config = test_config
+ self._test_config = port.test_configuration()
self._is_lint_mode = is_lint_mode
self._model = TestExpectationsModel()
self._parser = TestExpectationParser(port, tests, is_lint_mode)
self._port = port
self._skipped_tests_warnings = []
- self._expectations = self._parser.parse(expectations)
+ self._expectations = self._parser.parse(port.test_expectations())
self._add_expectations(self._expectations, in_overrides=False)
+ overrides = port.test_expectations_overrides()
if overrides:
overrides_expectations = self._parser.parse(overrides)
self._add_expectations(overrides_expectations, in_overrides=True)
self._expectations += overrides_expectations
- self._add_skipped_tests(skipped_tests or [])
+ # 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', []))))
self._has_warnings = False
self._report_warnings()
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py (117804 => 117805)
--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py 2012-05-21 18:52:16 UTC (rev 117805)
@@ -119,13 +119,9 @@
"""
def parse_exp(self, expectations, overrides=None, is_lint_mode=False):
- test_config = self._port.test_configuration()
- self._exp = TestExpectations(self._port,
- tests=self.get_basic_tests(),
- expectations=expectations,
- test_config=test_config,
- is_lint_mode=is_lint_mode,
- overrides=overrides)
+ self._port.test_expectations = lambda: expectations
+ self._port.test_expectations_overrides = lambda: overrides
+ self._exp = TestExpectations(self._port, self.get_basic_tests(), is_lint_mode)
def assert_exp(self, test, result):
self.assertEquals(self._exp.get_expectations(self.get_test(test)),
@@ -265,9 +261,10 @@
def check(self, expectations, overrides, skips, lint=False):
port = MockHost().port_factory.get('qt')
port._filesystem.write_text_file(port._filesystem.join(port.layout_tests_dir(), 'failures/expected/text.html'), 'foo')
- exp = TestExpectations(port, tests=['failures/expected/text.html'],
- expectations=expectations, overrides=overrides, is_lint_mode=lint,
- test_config=port.test_configuration(), skipped_tests=set(skips))
+ port.test_expectations = lambda: expectations
+ port.test_expectations_overrides = lambda: overrides
+ port.skipped_layout_tests = lambda tests: set(skips)
+ exp = TestExpectations(port, ['failures/expected/text.html'], lint)
# Check that the expectation is for BUG_DUMMY SKIP : ... = PASS
self.assertEquals(exp.get_modifiers('failures/expected/text.html'),
@@ -410,14 +407,10 @@
test_port.test_isfile = lambda test: True
test_config = test_port.test_configuration()
- expectations = TestExpectations(test_port,
- tests=self.get_basic_tests(),
- expectations="""BUGX LINUX WIN RELEASE : failures/expected/foo.html = TEXT
+ test_port.test_expectations = lambda: """BUGX LINUX WIN RELEASE : failures/expected/foo.html = TEXT
BUGY WIN MAC DEBUG : failures/expected/foo.html = CRASH
-""",
- test_config=test_config,
- is_lint_mode=False,
- overrides=None)
+"""
+ expectations = TestExpectations(test_port, self.get_basic_tests())
actual_expectations = expectations.remove_configuration_from_test('failures/expected/foo.html', test_config)
@@ -432,14 +425,10 @@
test_port.test_isfile = lambda test: True
test_config = test_port.test_configuration()
- expectations = TestExpectations(test_port,
- tests=None,
- expectations="""BUGX WIN RELEASE : failures/expected/foo.html = TEXT
+ test_port.test_expectations = lambda: """BUGX WIN RELEASE : failures/expected/foo.html = TEXT
BUGY WIN DEBUG : failures/expected/foo.html = CRASH
-""",
- test_config=test_config,
- is_lint_mode=False,
- overrides=None)
+"""
+ expectations = TestExpectations(test_port)
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())
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py (117804 => 117805)
--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py 2012-05-21 18:52:16 UTC (rev 117805)
@@ -46,7 +46,7 @@
_log = logging.getLogger(__name__)
-def lint(port, options, expectations_class):
+def lint(port, options):
host = port.host
if options.platform:
ports_to_lint = [port]
@@ -62,12 +62,7 @@
continue
try:
- expectations_class(port_to_lint,
- tests=None,
- expectations=port_to_lint.test_expectations(),
- test_config=port_to_lint.test_configuration(),
- is_lint_mode=True,
- overrides=port_to_lint.test_expectations_overrides())
+ test_expectations.TestExpectations(port_to_lint, is_lint_mode=True)
except test_expectations.ParseError, e:
lint_failed = True
_log.error('')
@@ -97,7 +92,7 @@
return 0
if options.lint_test_files:
- return lint(port, options, test_expectations.TestExpectations)
+ return lint(port, options)
# We wrap any parts of the run that are slow or likely to raise exceptions
# in a try/finally to ensure that we clean up the logging configuration.
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py (117804 => 117805)
--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py 2012-05-21 18:52:16 UTC (rev 117805)
@@ -192,11 +192,13 @@
def test_all_configurations(self):
class FakePort(object):
- def __init__(self, name, path):
+ def __init__(self, host, name, path):
+ self.host = host
self.name = name
self.path = path
def test_expectations(self):
+ self.host.ports_parsed.append(self.name)
return ''
def path_to_test_expectations_file(self):
@@ -208,14 +210,27 @@
def test_expectations_overrides(self):
return None
+ def skipped_layout_tests(self, tests):
+ return set([])
+
+ def all_test_configurations(self):
+ return []
+
+ def configuration_specifier_macros(self):
+ return []
+
+ def path_from_webkit_base(self):
+ return ''
+
+ def get_option(self, name, val):
+ return val
+
class FakeFactory(object):
def __init__(self, host, ports):
self.host = host
self.ports = {}
for port in ports:
self.ports[port.name] = port
- port.host = host
- port.factory = self
def get(self, port_name, *args, **kwargs):
return self.ports[port_name]
@@ -223,21 +238,17 @@
def all_port_names(self):
return sorted(self.ports.keys())
- class FakeExpectationsParser(object):
- def __init__(self, port, *args, **kwargs):
- port.host.ports_parsed.append(port.name)
-
host = MockHost()
host.ports_parsed = []
- host.port_factory = FakeFactory(host, (FakePort('a', 'path-to-a'),
- FakePort('b', 'path-to-b'),
- FakePort('b-win', 'path-to-b')))
+ host.port_factory = FakeFactory(host, (FakePort(host, 'a', 'path-to-a'),
+ FakePort(host, 'b', 'path-to-b'),
+ FakePort(host, 'b-win', 'path-to-b')))
- self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform=None), FakeExpectationsParser), 0)
+ self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform=None)), 0)
self.assertEquals(host.ports_parsed, ['a', 'b'])
host.ports_parsed = []
- self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform='a'), FakeExpectationsParser), 0)
+ self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform='a')), 0)
self.assertEquals(host.ports_parsed, ['a'])
def test_lint_test_files(self):
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/views/printing_unittest.py (117804 => 117805)
--- trunk/Tools/Scripts/webkitpy/layout_tests/views/printing_unittest.py 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/views/printing_unittest.py 2012-05-21 18:52:16 UTC (rev 117805)
@@ -126,10 +126,9 @@
return test_results.TestResult(test_name, failures=failures, test_run_time=run_time)
def get_result_summary(self, test_names, expectations_str):
- expectations = test_expectations.TestExpectations(
- self._port, test_names, expectations_str,
- self._port.test_configuration(),
- is_lint_mode=False)
+ port.test_expectations = lambda: expectations_str
+ port.test_expectations_overrides = lambda: None
+ expectations = test_expectations.TestExpectations(self._port, test_names)
rs = result_summary.ResultSummary(expectations, test_names)
return test_names, rs, expectations
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py (117804 => 117805)
--- trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py 2012-05-21 18:52:16 UTC (rev 117805)
@@ -79,13 +79,21 @@
def check_test_expectations(self, expectations_str, tests=None, overrides=None):
err = None
expectations = None
+ # FIXME: We need to rework how we lint strings so that we can do it independently of what a
+ # port's existing expectations are. Linting should probably just call the parser directly.
+ # For now we override the port hooks. This will also need to be reworked when expectations
+ # can cascade arbitrarily, rather than just have expectations and overrides.
+ orig_expectations = self._port_obj.test_expectations
+ orig_overrides = self._port_obj.test_expectations_overrides
try:
- expectations = test_expectations.TestExpectations(
- port=self._port_obj, expectations=expectations_str, tests=tests,
- test_config=self._port_obj.test_configuration(),
- is_lint_mode=True, overrides=overrides)
+ self._port_obj.test_expectations = lambda: expectations_str
+ self._port_obj.test_expectations_overrides = lambda: overrides
+ expectations = test_expectations.TestExpectations(self._port_obj, tests, True)
except test_expectations.ParseError, error:
err = error
+ finally:
+ self._port_obj.text_expectations = orig_expectations
+ self._port_obj.text_expectations_overrides = orig_overrides
if err:
level = 5
Modified: trunk/Tools/Scripts/webkitpy/tool/commands/queries.py (117804 => 117805)
--- trunk/Tools/Scripts/webkitpy/tool/commands/queries.py 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/queries.py 2012-05-21 18:52:16 UTC (rev 117805)
@@ -456,13 +456,7 @@
port = self._tool.port_factory.get(port_name, options)
expectations_path = port.path_to_test_expectations_file()
if not expectations_path in self._expectation_models:
- lint_mode = False
- self._expectation_models[expectations_path] = TestExpectations(port, tests,
- port.test_expectations(),
- port.test_configuration(),
- lint_mode,
- port.test_expectations_overrides(),
- port.skipped_layout_tests(tests)).model()
+ self._expectation_models[expectations_path] = TestExpectations(port, tests).model()
return self._expectation_models[expectations_path]
Modified: trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py (117804 => 117805)
--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py 2012-05-21 18:50:36 UTC (rev 117804)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py 2012-05-21 18:52:16 UTC (rev 117805)
@@ -121,8 +121,7 @@
def _update_expectations_file(self, builder_name, test_name):
port = self._tool.port_factory.get_from_builder_name(builder_name)
- expectationsString = port.test_expectations()
- expectations = TestExpectations(port, None, expectationsString, port.test_configuration())
+ expectations = TestExpectations(port)
for test_configuration in port.all_test_configurations():
if test_configuration.version == port.test_configuration().version:
@@ -239,7 +238,7 @@
return port_name.startswith('chromium-')
def _expectations(self, port):
- return TestExpectations(port, None, port.test_expectations(), port.test_configuration())
+ return TestExpectations(port)
def _update_expectations_file(self, port_name):
if not self._is_supported_port(port_name):