webkitpy: clean up options for specifying multiple platforms at once
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Nov 2012 19:24:39 +0000 (19:24 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Nov 2012 19:24:39 +0000 (19:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=101140

Reviewed by Ojan Vafai.

This patch reworks how we display the help strings for --platform
options and how we filter out platforms matching a glob. This will
be useful as I add patches to ensure that all the webkit-patch
commands are using --platform consistently to filter ports.

There should be no functional changes resulting from this patch.

* Scripts/webkitpy/layout_tests/port/factory.py:
(platform_options):
(PortFactory.all_port_names):
(PortFactory.get_from_builder_name):
* Scripts/webkitpy/tool/commands/queries.py:
(PrintExpectations.__init__):
(PrintBaselines.__init__):
* Scripts/webkitpy/tool/commands/rebaseline.py:
(AbstractRebaseliningCommand):
(RebaselineJson.__init__):
* Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
(TestRebaselineExpectations.setUp):
(TestRebaselineExpectations.test_rebaseline_expectations):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/port/factory.py
Tools/Scripts/webkitpy/tool/commands/queries.py
Tools/Scripts/webkitpy/tool/commands/rebaseline.py
Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py

index ccad61f..7b7ee9c 100644 (file)
@@ -1,3 +1,31 @@
+2012-11-05  Dirk Pranke  <dpranke@chromium.org>
+
+        webkitpy: clean up options for specifying multiple platforms at once
+        https://bugs.webkit.org/show_bug.cgi?id=101140
+
+        Reviewed by Ojan Vafai.
+
+        This patch reworks how we display the help strings for --platform
+        options and how we filter out platforms matching a glob. This will
+        be useful as I add patches to ensure that all the webkit-patch
+        commands are using --platform consistently to filter ports.
+
+        There should be no functional changes resulting from this patch.
+
+        * Scripts/webkitpy/layout_tests/port/factory.py:
+        (platform_options):
+        (PortFactory.all_port_names):
+        (PortFactory.get_from_builder_name):
+        * Scripts/webkitpy/tool/commands/queries.py:
+        (PrintExpectations.__init__):
+        (PrintBaselines.__init__):
+        * Scripts/webkitpy/tool/commands/rebaseline.py:
+        (AbstractRebaseliningCommand):
+        (RebaselineJson.__init__):
+        * Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
+        (TestRebaselineExpectations.setUp):
+        (TestRebaselineExpectations.test_rebaseline_expectations):
+
 2012-11-05  Peter Beverloo  <peter@chromium.org>
 
         The layout test runner shouldn't wait for data if stdout/stderr have been closed
index f68164e..ad7c644 100644 (file)
 
 """Factory method to retrieve the appropriate port implementation."""
 
+import fnmatch
 import optparse
 import re
 
 from webkitpy.layout_tests.port import builders
 
 
-def platform_options(**help_strings):
+def platform_options(use_globs=False):
     return [
         optparse.make_option('--platform', action='store',
-            help=help_strings.get('platform', 'Platform/Port being tested (e.g., "mac-lion")')),
-        optparse.make_option('--chromium', action='store_const', const='chromium', dest='platform',
-            help='Alias for --platform=chromium'),
-        optparse.make_option('--chromium-android', action='store_const', const='chromium-android', dest='platform',
-            help='Alias for --platform=chromium-android'),
-        optparse.make_option('--efl', action='store_const', const='efl', dest="platform",
-            help='Alias for --platform=efl'),
-        optparse.make_option('--gtk', action='store_const', const='gtk', dest="platform",
-            help='Alias for --platform=gtk'),
-        optparse.make_option('--qt', action='store_const', const='qt', dest="platform",
-            help='Alias for --platform=qt'),
+            help=('Glob-style list of platform/ports to use (e.g., "mac*")' if use_globs else 'Platform to use (e.g., "mac-lion")')),
+        optparse.make_option('--chromium', action='store_const', dest='platform',
+            const=('chromium*' if use_globs else 'chromium'),
+            help=('Alias for --platform=chromium*' if use_globs else 'Alias for --platform=chromium')),
+        optparse.make_option('--chromium-android', action='store_const', dest='platform',
+            const=('chromium-android*' if use_globs else 'chromium-android'),
+            help=('Alias for --platform=chromium-android*' if use_globs else 'Alias for --platform=chromium')),
+        optparse.make_option('--efl', action='store_const', dest='platform',
+            const=('efl*' if use_globs else 'efl'),
+            help=('Alias for --platform=efl*' if use_globs else 'Alias for --platform=efl')),
+        optparse.make_option('--gtk', action='store_const', dest='platform',
+            const=('gtk*' if use_globs else 'gtk'),
+            help=('Alias for --platform=gtk*' if use_globs else 'Alias for --platform=gtk')),
+        optparse.make_option('--qt', action='store_const', dest="platform",
+            const=('qt*' if use_globs else 'qt'),
+            help=('Alias for --platform=qt' if use_globs else 'Alias for --platform=qt')),
         ]
 
 
@@ -122,18 +128,18 @@ class PortFactory(object):
                 return cls(self._host, port_name, options=options, **kwargs)
         raise NotImplementedError('unsupported platform: "%s"' % port_name)
 
-    def all_port_names(self):
+    def all_port_names(self, platform=None):
         """Return a list of all valid, fully-specified, "real" port names.
 
         This is the list of directories that are used as actual baseline_paths()
         by real ports. This does not include any "fake" names like "test"
-        or "mock-mac", and it does not include any directories that are not ."""
-        # FIXME: There's probably a better way to generate this list ...
-        return builders.all_port_names()
+        or "mock-mac", and it does not include any directories that are not.
+
+        If platform is not specified, we will glob-match all ports"""
+        platform = platform or '*'
+        return fnmatch.filter(builders.all_port_names(), platform)
 
     def get_from_builder_name(self, builder_name):
         port_name = builders.port_name_for_builder_name(builder_name)
-        assert(port_name)  # Need to update port_name_for_builder_name
-        port = self.get(port_name, _builder_options(builder_name))
-        assert(port)  # Need to update port_name_for_builder_name
-        return port
+        assert port_name, "unrecognized builder name '%s'" % builder_name
+        return self.get(port_name, _builder_options(builder_name))
index 91083f5..b7e4a85 100644 (file)
@@ -440,7 +440,7 @@ class PrintExpectations(AbstractDeclarativeCommand):
                         help='Print a CSV-style report that includes the port name, modifiers, tests, and expectations'),
             make_option('-f', '--full', action='store_true', default=False,
                         help='Print a full TestExpectations-style line for every match'),
-        ] + platform_options(platform='port/platform to use. Use glob-style wildcards for multiple ports (implies --csv)') + configuration_options()
+        ] + platform_options(use_globs=True)
 
         AbstractDeclarativeCommand.__init__(self, options=options)
         self._expectation_models = {}
@@ -519,7 +519,7 @@ class PrintBaselines(AbstractDeclarativeCommand):
                         help='Print a CSV-style report that includes the port name, test_name, test platform, baseline type, baseline location, and baseline platform'),
             make_option('--include-virtual-tests', action='store_true',
                         help='Include virtual tests'),
-        ] + platform_options(platform='port/platform to use. Use glob-style wildcards for multiple ports (implies --csv)') + configuration_options()
+        ] + platform_options(use_globs=True)
         AbstractDeclarativeCommand.__init__(self, options=options)
         self._platform_regexp = re.compile('platform/([^\/]+)/(.+)')
 
index effe6ce..e162e73 100644 (file)
@@ -67,7 +67,7 @@ class AbstractRebaseliningCommand(AbstractDeclarativeCommand):
         help=('Do not optimize/de-dup the expectations after rebaselining (default is to de-dup automatically). '
               'You can use "webkit-patch optimize-baselines" to optimize separately.'))
 
-    platform_options = factory.platform_options()
+    platform_options = factory.platform_options(use_globs=True)
 
     results_directory_option = optparse.make_option("--results-directory", help="Local results directory to use")
 
@@ -353,7 +353,7 @@ class RebaselineJson(AbstractParallelRebaselineCommand):
     help_text = "Rebaseline based off JSON passed to stdin. Intended to only be called from other scripts."
 
     def __init__(self,):
-        return super(RebaselineJson, self).__init__(options=[
+        super(RebaselineJson, self).__init__(options=[
             self.move_overwritten_baselines_option,
             self.no_optimize_option,
             self.results_directory_option,
index 2727a26..b5c0d0d 100644 (file)
@@ -312,7 +312,8 @@ class TestRebaselineExpectations(_BaseTestCase):
 
     def setUp(self):
         super(TestRebaselineExpectations, self).setUp()
-        self.options = MockOptions(optimize=True, builders=None, suffixes=['txt'], verbose=False)
+        self.options = MockOptions(optimize=False, builders=None, suffixes=['txt'], verbose=False, platform=None,
+                                   move_overwritten_baselines=False, results_directory=None)
 
     def test_rebaseline_expectations(self):
         self._zero_out_test_expectations()
@@ -320,7 +321,7 @@ class TestRebaselineExpectations(_BaseTestCase):
         self.tool.executive = MockExecutive2()
 
         self.command._tests_to_rebaseline = lambda port: {'userscripts/another-test.html': set(['txt']), 'userscripts/images.svg': set(['png'])}
-        self.command.execute(MockOptions(optimize=False, verbose=False, move_overwritten_baselines=False, results_directory=None), [], self.tool)
+        self.command.execute(self.options, [], self.tool)
 
         # FIXME: change this to use the test- ports.
         calls = filter(lambda x: x != ['qmake', '-v'], self.tool.executive.calls)