Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline.py

Issue 2128233003: Split out optimize-baselines command from rebaseline.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2010 Google Inc. All rights reserved. 1 # Copyright (c) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the 11 # in the documentation and/or other materials provided with the
12 # distribution. 12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its 13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from 14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission. 15 # this software without specific prior written permission.
16 # 16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR/ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR/ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29
30 from __future__ import print_function 29 from __future__ import print_function
31 import json 30 import json
32 import logging 31 import logging
33 import optparse 32 import optparse
34 import re 33 import re
35 import sys 34 import sys
36 import time 35 import time
37 import traceback 36 import traceback
38 import urllib2 37 import urllib2
39 38
40 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer
41 from webkitpy.common.memoized import memoized 39 from webkitpy.common.memoized import memoized
42 from webkitpy.common.system.executive import ScriptError 40 from webkitpy.common.system.executive import ScriptError
43 from webkitpy.layout_tests.controllers.test_result_writer import baseline_name
44 from webkitpy.layout_tests.models.test_expectations import TestExpectations, BAS ELINE_SUFFIX_LIST, SKIP 41 from webkitpy.layout_tests.models.test_expectations import TestExpectations, BAS ELINE_SUFFIX_LIST, SKIP
45 from webkitpy.layout_tests.port import factory 42 from webkitpy.layout_tests.port import factory
46 from webkitpy.tool.commands.command import Command 43 from webkitpy.tool.commands.command import Command
47 44
48 45
49 _log = logging.getLogger(__name__) 46 _log = logging.getLogger(__name__)
50 47
51 48
52 class AbstractRebaseliningCommand(Command): 49 class AbstractRebaseliningCommand(Command):
53 """Base class for rebaseline-related commands.""" 50 """Base class for rebaseline-related commands."""
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 226
230 for suffix in self._baseline_suffix_list: 227 for suffix in self._baseline_suffix_list:
231 self._rebaseline_test(options.builder, options.test, suffix, results _url) 228 self._rebaseline_test(options.builder, options.test, suffix, results _url)
232 self._scm_changes['remove-lines'].append({'builder': options.builder, 't est': options.test}) 229 self._scm_changes['remove-lines'].append({'builder': options.builder, 't est': options.test})
233 230
234 def execute(self, options, args, tool): 231 def execute(self, options, args, tool):
235 self._rebaseline_test_and_update_expectations(options) 232 self._rebaseline_test_and_update_expectations(options)
236 self._print_scm_changes() 233 self._print_scm_changes()
237 234
238 235
239 class OptimizeBaselines(AbstractRebaseliningCommand):
240 name = "optimize-baselines"
241 help_text = "Reshuffles the baselines for the given tests to use as litte sp ace on disk as possible."
242 show_in_main_help = True
243 argument_names = "TEST_NAMES"
244
245 def __init__(self):
246 super(OptimizeBaselines, self).__init__(options=[
247 self.suffixes_option,
248 optparse.make_option('--no-modify-scm', action='store_true', default =False,
249 help='Dump SCM commands as JSON instead of actu ally committing changes.'),
250 ] + self.platform_options)
251
252 def _optimize_baseline(self, optimizer, test_name):
253 files_to_delete = []
254 files_to_add = []
255 for suffix in self._baseline_suffix_list:
256 name = baseline_name(self._tool.filesystem, test_name, suffix)
257 succeeded, more_files_to_delete, more_files_to_add = optimizer.optim ize(name)
258 if not succeeded:
259 _log.error("Heuristics failed to optimize %s", name)
260 files_to_delete.extend(more_files_to_delete)
261 files_to_add.extend(more_files_to_add)
262 return files_to_delete, files_to_add
263
264 def execute(self, options, args, tool):
265 self._baseline_suffix_list = options.suffixes.split(',')
266 port_names = tool.port_factory.all_port_names(options.platform)
267 if not port_names:
268 _log.error("No port names match '%s'", options.platform)
269 return
270 port = tool.port_factory.get(port_names[0])
271 optimizer = BaselineOptimizer(tool, port, port_names, skip_scm_commands= options.no_modify_scm)
272 tests = port.tests(args)
273 for test_name in tests:
274 files_to_delete, files_to_add = self._optimize_baseline(optimizer, t est_name)
275 for path in files_to_delete:
276 self._delete_from_scm_later(path)
277 for path in files_to_add:
278 self._add_to_scm_later(path)
279 self._print_scm_changes()
280
281
282 class AbstractParallelRebaselineCommand(AbstractRebaseliningCommand): 236 class AbstractParallelRebaselineCommand(AbstractRebaseliningCommand):
283 """Base class for rebaseline commands that do some tasks in parallel.""" 237 """Base class for rebaseline commands that do some tasks in parallel."""
284 # Not overriding execute() - pylint: disable=abstract-method 238 # Not overriding execute() - pylint: disable=abstract-method
285 239
286 def __init__(self, options=None): 240 def __init__(self, options=None):
287 super(AbstractParallelRebaselineCommand, self).__init__(options=options) 241 super(AbstractParallelRebaselineCommand, self).__init__(options=options)
288 self._builder_data = {} 242 self._builder_data = {}
289 243
290 def builder_data(self): 244 def builder_data(self):
291 if not self._builder_data: 245 if not self._builder_data:
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 issue_already_closed = tool.executive.run_command( 869 issue_already_closed = tool.executive.run_command(
916 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline _branch_name], 870 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline _branch_name],
917 return_exit_code=True) 871 return_exit_code=True)
918 if not issue_already_closed: 872 if not issue_already_closed:
919 self._run_git_cl_command(options, ['set_close']) 873 self._run_git_cl_command(options, ['set_close'])
920 874
921 tool.scm().ensure_cleanly_tracking_remote_master() 875 tool.scm().ensure_cleanly_tracking_remote_master()
922 if old_branch_name_or_ref: 876 if old_branch_name_or_ref:
923 tool.scm().checkout_branch(old_branch_name_or_ref) 877 tool.scm().checkout_branch(old_branch_name_or_ref)
924 tool.scm().delete_branch(rebaseline_branch_name) 878 tool.scm().delete_branch(rebaseline_branch_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698