webkit-patch optimize-baselines should take a --platform arg
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Nov 2012 19:28:01 +0000 (19:28 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Nov 2012 19:28:01 +0000 (19:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97623

Reviewed by Ojan Vafai.

So that we can optionally limit/control which platforms' results
are affected.

This patch adds --platform to analyze-baselines as well.

* Scripts/webkitpy/common/checkout/baselineoptimizer.py:
(_baseline_search_hypergraph):
(BaselineOptimizer.__init__):
* Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py:
(TestBaselineOptimizer.__init__):
(BaselineOptimizerTest.test_move_baselines):
* Scripts/webkitpy/tool/commands/rebaseline.py:
(OptimizeBaselines.__init__):
(OptimizeBaselines.execute):
(AnalyzeBaselines.__init__):
(AnalyzeBaselines.execute):
* Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
(TestAnalyzeBaselines.test_default):
(TestAnalyzeBaselines.test_missing_baselines):

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

Tools/ChangeLog
Tools/Scripts/webkitpy/common/checkout/baselineoptimizer.py
Tools/Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py
Tools/Scripts/webkitpy/tool/commands/rebaseline.py
Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py

index fded788..6dc1f63 100644 (file)
@@ -1,5 +1,32 @@
 2012-11-05  Dirk Pranke  <dpranke@chromium.org>
 
+        webkit-patch optimize-baselines should take a --platform arg
+        https://bugs.webkit.org/show_bug.cgi?id=97623
+
+        Reviewed by Ojan Vafai.
+
+        So that we can optionally limit/control which platforms' results
+        are affected.
+
+        This patch adds --platform to analyze-baselines as well.
+
+        * Scripts/webkitpy/common/checkout/baselineoptimizer.py:
+        (_baseline_search_hypergraph):
+        (BaselineOptimizer.__init__):
+        * Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py:
+        (TestBaselineOptimizer.__init__):
+        (BaselineOptimizerTest.test_move_baselines):
+        * Scripts/webkitpy/tool/commands/rebaseline.py:
+        (OptimizeBaselines.__init__):
+        (OptimizeBaselines.execute):
+        (AnalyzeBaselines.__init__):
+        (AnalyzeBaselines.execute):
+        * Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
+        (TestAnalyzeBaselines.test_default):
+        (TestAnalyzeBaselines.test_missing_baselines):
+
+2012-11-05  Dirk Pranke  <dpranke@chromium.org>
+
         webkit-patch rebaseline-expectations should take a --platform arg
         https://bugs.webkit.org/show_bug.cgi?id=97621
 
index 641b0ab..d2d53a5 100644 (file)
@@ -32,10 +32,11 @@ import logging
 
 _log = logging.getLogger(__name__)
 
+
 # Yes, it's a hypergraph.
 # FIXME: Should this function live with the ports somewhere?
 # Perhaps this should move onto PortFactory?
-def _baseline_search_hypergraph(host):
+def _baseline_search_hypergraph(host, port_names):
     hypergraph = {}
 
     # These edges in the hypergraph aren't visible on build.webkit.org,
@@ -46,7 +47,7 @@ def _baseline_search_hypergraph(host):
     fallback_path = ['LayoutTests']
 
     port_factory = host.port_factory
-    for port_name in port_factory.all_port_names():
+    for port_name in port_names:
         port = port_factory.get(port_name)
         webkit_base = port.webkit_base()
         search_path = port.baseline_search_path()
@@ -74,11 +75,11 @@ def _invert_dictionary(dictionary):
 
 
 class BaselineOptimizer(object):
-    def __init__(self, host):
+    def __init__(self, host, port_names):
         self._host = host
         self._filesystem = self._host.filesystem
         self._scm = self._host.scm()
-        self._hypergraph = _baseline_search_hypergraph(host)
+        self._hypergraph = _baseline_search_hypergraph(host, port_names)
         self._directories = reduce(set.union, map(set, self._hypergraph.values()))
 
     def read_results_by_directory(self, baseline_name):
index 0521730..a5fd065 100644 (file)
@@ -37,7 +37,7 @@ from webkitpy.common.host_mock import MockHost
 class TestBaselineOptimizer(BaselineOptimizer):
     def __init__(self, mock_results_by_directory):
         host = MockHost()
-        BaselineOptimizer.__init__(self, host)
+        BaselineOptimizer.__init__(self, host, host.port_factory.all_port_names())
         self._mock_results_by_directory = mock_results_by_directory
 
     # We override this method for testing so we don't have to construct an
@@ -64,7 +64,7 @@ class BaselineOptimizerTest(unittest.TestCase):
         host.filesystem.write_binary_file('/mock-checkout/LayoutTests/platform/chromium-win/another/test-expected.txt', 'result A')
         host.filesystem.write_binary_file('/mock-checkout/LayoutTests/platform/chromium-mac/another/test-expected.txt', 'result A')
         host.filesystem.write_binary_file('/mock-checkout/LayoutTests/platform/chromium/another/test-expected.txt', 'result B')
-        baseline_optimizer = BaselineOptimizer(host)
+        baseline_optimizer = BaselineOptimizer(host, host.port_factory.all_port_names())
         baseline_optimizer._move_baselines('another/test-expected.txt', {
             'LayoutTests/platform/chromium-win': 'aaa',
             'LayoutTests/platform/chromium-mac': 'aaa',
index daedbc2..bb95a29 100644 (file)
@@ -208,7 +208,7 @@ class OptimizeBaselines(AbstractRebaseliningCommand):
     argument_names = "TEST_NAMES"
 
     def __init__(self):
-        return super(OptimizeBaselines, self).__init__(options=[self.suffixes_option])
+        super(OptimizeBaselines, self).__init__(options=[self.suffixes_option] + self.platform_options)
 
     def _optimize_baseline(self, test_name):
         for suffix in self._baseline_suffix_list:
@@ -218,8 +218,13 @@ class OptimizeBaselines(AbstractRebaseliningCommand):
 
     def execute(self, options, args, tool):
         self._baseline_suffix_list = options.suffixes.split(',')
-        self._baseline_optimizer = BaselineOptimizer(tool)
-        self._port = tool.port_factory.get()
+        port_names = tool.port_factory.all_port_names(options.platform)
+        if not port_names:
+            print "No port names match '%s'" % options.platform
+            return
+
+        self._baseline_optimizer = BaselineOptimizer(tool, port_names)
+        self._port = tool.port_factory.get(port_names[0])
         for test_name in self._port.tests(args):
             _log.info("Optimizing %s" % test_name)
             self._optimize_baseline(test_name)
@@ -234,7 +239,7 @@ class AnalyzeBaselines(AbstractRebaseliningCommand):
         super(AnalyzeBaselines, self).__init__(options=[
             self.suffixes_option,
             optparse.make_option('--missing', action='store_true', default=False, help='show missing baselines as well'),
-            ])
+            ] + self.platform_options)
         self._optimizer_class = BaselineOptimizer  # overridable for testing
 
     def _write(self, msg):
@@ -252,8 +257,13 @@ class AnalyzeBaselines(AbstractRebaseliningCommand):
 
     def execute(self, options, args, tool):
         self._baseline_suffix_list = options.suffixes.split(',')
-        self._baseline_optimizer = self._optimizer_class(tool)
-        self._port = tool.port_factory.get()
+        port_names = tool.port_factory.all_port_names(options.platform)
+        if not port_names:
+            print "No port names match '%s'" % options.platform
+            return
+
+        self._baseline_optimizer = self._optimizer_class(tool, port_names)
+        self._port = tool.port_factory.get(port_names[0])
         for test_name in self._port.tests(args):
             self._analyze_baseline(options, test_name)
 
index b5c0d0d..3bf1888 100644 (file)
@@ -376,14 +376,14 @@ class TestAnalyzeBaselines(_BaseTestCase):
         self.command._write = lambda msg: self.lines.append(msg)
 
     def test_default(self):
-        self.command.execute(MockOptions(suffixes='txt', missing=False), ['passes/text.html'], self.tool)
+        self.command.execute(MockOptions(suffixes='txt', missing=False, platform=None), ['passes/text.html'], self.tool)
         self.assertEquals(self.lines,
             ['passes/text-expected.txt:',
              '  (generic): 123456',
              '  test-mac-leopard: abcdef'])
 
     def test_missing_baselines(self):
-        self.command.execute(MockOptions(suffixes='png,txt', missing=True), ['passes/text.html'], self.tool)
+        self.command.execute(MockOptions(suffixes='png,txt', missing=True, platform=None), ['passes/text.html'], self.tool)
         self.assertEquals(self.lines,
             ['passes/text-expected.png: (no baselines found)',
              'passes/text-expected.txt:',