Title: [105936] trunk/Tools
Revision
105936
Author
[email protected]
Date
2012-01-25 15:52:52 -0800 (Wed, 25 Jan 2012)

Log Message

run-webkit-tests --lint-test-files should lint all the ports by default
https://bugs.webkit.org/show_bug.cgi?id=76749

Reviewed by Ojan Vafai.

Currently run-webkit-tests --lint-test-files will only lint the
test_expectations for the single port determined by the command
line options. This is not obvious and can produce unintended results
if you want to lint the chromium port (probably the normal case
for using --lint-test-files) but don't specify a port name or
--chromium.

I think we should probably lint *all* of the ports if no port
name is supplied. This change implements that, and also moves
the linting logic out of the Manager class, since this really
has nothing to do with Managers. It has little to do with
run-webkit-tests, but splitting it into a different script would
introduce compatibility issues. It might make sense to do that
anyway, in a separate patch and combining that with cleaning up
the style checker to share more code.

* Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager._strip_test_dir_prefix):
* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(lint):
(run):
* Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
(LintTest.test_all_configurations): added.
(LintTest.test_lint_test_files): added.
(LintTest.test_lint_test_files__errors): added.
(MainTest.test_lint_test_files): removed.
(MainTest.test_lint_test_files__errors): removed.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (105935 => 105936)


--- trunk/Tools/ChangeLog	2012-01-25 23:46:02 UTC (rev 105935)
+++ trunk/Tools/ChangeLog	2012-01-25 23:52:52 UTC (rev 105936)
@@ -1,5 +1,40 @@
 2012-01-25  Dirk Pranke  <[email protected]>
 
+        run-webkit-tests --lint-test-files should lint all the ports by default
+        https://bugs.webkit.org/show_bug.cgi?id=76749
+
+        Reviewed by Ojan Vafai.
+
+        Currently run-webkit-tests --lint-test-files will only lint the
+        test_expectations for the single port determined by the command
+        line options. This is not obvious and can produce unintended results
+        if you want to lint the chromium port (probably the normal case
+        for using --lint-test-files) but don't specify a port name or
+        --chromium.
+
+        I think we should probably lint *all* of the ports if no port
+        name is supplied. This change implements that, and also moves
+        the linting logic out of the Manager class, since this really
+        has nothing to do with Managers. It has little to do with
+        run-webkit-tests, but splitting it into a different script would
+        introduce compatibility issues. It might make sense to do that
+        anyway, in a separate patch and combining that with cleaning up
+        the style checker to share more code.
+
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        (Manager._strip_test_dir_prefix):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        (lint):
+        (run):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
+        (LintTest.test_all_configurations): added.
+        (LintTest.test_lint_test_files): added.
+        (LintTest.test_lint_test_files__errors): added.
+        (MainTest.test_lint_test_files): removed.
+        (MainTest.test_lint_test_files__errors): removed.
+
+2012-01-25  Dirk Pranke  <[email protected]>
+
         webkitpy: clean up a bunch of test scaffolding
         https://bugs.webkit.org/show_bug.cgi?id=76973
 
@@ -21,6 +56,29 @@
         * Scripts/webkitpy/test/echo.py: Removed.
         * Scripts/webkitpy/test/echo_unittest.py: Removed.
 
+2012-01-25  Dirk Pranke  <[email protected]>
+
+        webkitpy: clean up a bunch of test scaffolding
+        https://bugs.webkit.org/show_bug.cgi?id=76973
+
+        Reviewed by Eric Seidel.
+
+        There were several helper modules in the webkitpy.test package
+        that appear to only be used by executive_unittest.py. I am
+        rolling them all into that file to make that clearer.
+
+        * Scripts/webkitpy/common/system/executive_unittest.py:
+        (ExecutiveTest.test_run_command_args_type):
+        (ExecutiveTest.test_run_command_with_unicode):
+        (ExecutiveTest.test_running_pids):
+        (command_line):
+        (main):
+        * Scripts/webkitpy/common/system/fileutils.py: Removed.
+        * Scripts/webkitpy/test/cat.py: Removed.
+        * Scripts/webkitpy/test/cat_unittest.py: Removed.
+        * Scripts/webkitpy/test/echo.py: Removed.
+        * Scripts/webkitpy/test/echo_unittest.py: Removed.
+
 2012-01-25  Eric Seidel  <[email protected]>
 
         Remove Python 2.5 support from WebKit

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (105935 => 105936)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2012-01-25 23:46:02 UTC (rev 105935)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2012-01-25 23:52:52 UTC (rev 105936)
@@ -347,25 +347,6 @@
             return path[len(self.LAYOUT_TESTS_DIRECTORY + self._filesystem.sep):]
         return path
 
-    def lint(self):
-        try:
-            test_expectations.TestExpectations(
-                self._port,
-                None,
-                self._port.test_expectations(),
-                self._port.test_configuration(),
-                self._options.lint_test_files,
-                self._port.test_expectations_overrides())
-        except test_expectations.ParseError, err:
-            for error in err.errors:
-                self._printer.write(error)
-            self._printer.write("")
-            _log.error("Lint failed.")
-            return -1
-
-        _log.info("Lint succeeded.")
-        return 0
-
     def _is_http_test(self, test):
         return self.HTTP_SUBDIR in test or self.WEBSOCKET_SUBDIR in test
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py (105935 => 105936)


--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2012-01-25 23:46:02 UTC (rev 105935)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2012-01-25 23:52:52 UTC (rev 105936)
@@ -38,12 +38,50 @@
 
 from webkitpy.common.host import Host
 from webkitpy.layout_tests.controllers.manager import Manager, WorkerException
+from webkitpy.layout_tests.models import test_expectations
 from webkitpy.layout_tests.views import printing
 
 
 _log = logging.getLogger(__name__)
 
 
+def lint(port, options, expectations_class):
+    host = port.host
+    if options.platform:
+        ports_to_lint = [port]
+    else:
+        ports_to_lint = [host.port_factory.get(name) for name in host.port_factory.all_port_names()]
+
+    files_linted = set()
+    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
+
+        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())
+        except test_expectations.ParseError, e:
+            lint_failed = True
+            _log.error('')
+            for error in e.errors:
+                _log.error(error)
+            _log.error('')
+        files_linted.add(expectations_file)
+
+    if lint_failed:
+        _log.error('Lint failed.')
+        return -1
+    _log.info('Lint succeeded.')
+    return 0
+
+
 def run(port, options, args, regular_output=sys.stderr, buildbot_output=sys.stdout):
     warnings = _set_up_derived_options(port, options)
 
@@ -57,6 +95,9 @@
         printer.cleanup()
         return 0
 
+    if options.lint_test_files:
+        return lint(port, options, test_expectations.TestExpectations)
+
     # 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.
     unexpected_result_count = -1
@@ -64,9 +105,6 @@
         manager = Manager(port, options, printer)
         manager.print_config()
 
-        if options.lint_test_files:
-            return manager.lint()
-
         printer.print_update("Collecting tests ...")
         try:
             manager.collect_tests(args)

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py (105935 => 105936)


--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py	2012-01-25 23:46:02 UTC (rev 105935)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py	2012-01-25 23:52:52 UTC (rev 105936)
@@ -71,6 +71,7 @@
 from webkitpy.layout_tests.port import Port
 from webkitpy.layout_tests.port.test import TestPort, TestDriver
 from webkitpy.test.skip import skip_if
+from webkitpy.tool.mocktool import MockOptions
 
 
 def parse_args(extra_args=None, record_results=False, tests_included=False, new_results=False, print_nothing=True):
@@ -188,6 +189,76 @@
 unexpected_tests_count = 12
 
 
+class LintTest(unittest.TestCase):
+    def test_all_configurations(self):
+
+        class FakePort(object):
+            def __init__(self, name, path):
+                self.name = name
+                self.path = path
+
+            def test_expectations(self):
+                return ''
+
+            def path_to_test_expectations_file(self):
+                return self.path
+
+            def test_configuration(self):
+                return None
+
+            def test_expectations_overrides(self):
+                return None
+
+        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]
+
+            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')))
+
+        self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform=None), FakeExpectationsParser), 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(host.ports_parsed, ['a'])
+
+    def test_lint_test_files(self):
+        res, out, err, user = logging_run(['--lint-test-files'])
+        self.assertEqual(res, 0)
+        self.assertTrue(out.empty())
+        self.assertTrue(any(['Lint succeeded' in msg for msg in err.get()]))
+
+    def test_lint_test_files__errors(self):
+        options, parsed_args = parse_args(['--lint-test-files'])
+        host = MockHost()
+        port_obj = host.port_factory.get(options.platform, options=options)
+        port_obj.test_expectations = lambda: "# syntax error"
+        res, out, err = run_and_capture(port_obj, options, parsed_args)
+
+        self.assertEqual(res, -1)
+        self.assertTrue(out.empty())
+        self.assertTrue(any(['Lint failed' in msg for msg in err.get()]))
+
+
 class MainTest(unittest.TestCase):
     def test_accelerated_compositing(self):
         # This just tests that we recognize the command line args
@@ -284,23 +355,6 @@
             ['failures/expected/keyboard.html', '--worker-model', 'inline'],
             tests_included=True)
 
-    def test_lint_test_files(self):
-        res, out, err, user = logging_run(['--lint-test-files'])
-        self.assertEqual(res, 0)
-        self.assertTrue(out.empty())
-        self.assertTrue(any(['Lint succeeded' in msg for msg in err.get()]))
-
-    def test_lint_test_files__errors(self):
-        options, parsed_args = parse_args(['--lint-test-files'])
-        host = MockHost()
-        port_obj = host.port_factory.get(options.platform, options=options)
-        port_obj.test_expectations = lambda: "# syntax error"
-        res, out, err = run_and_capture(port_obj, options, parsed_args)
-
-        self.assertEqual(res, -1)
-        self.assertTrue(out.empty())
-        self.assertTrue(any(['Lint failed' in msg for msg in err.get()]))
-
     def test_no_tests_found(self):
         res, out, err, user = logging_run(['resources'], tests_included=True)
         self.assertEqual(res, -1)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to