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

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

Issue 2397573002: Don't track SCM changes in rebaseline commands. (Closed)
Patch Set: Update message and docstring for has_working_directory_changes Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import optparse
7 6
8 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer 7 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer
9 from webkitpy.layout_tests.controllers.test_result_writer import baseline_name 8 from webkitpy.layout_tests.controllers.test_result_writer import baseline_name
10 from webkitpy.tool.commands.rebaseline import AbstractRebaseliningCommand 9 from webkitpy.tool.commands.rebaseline import AbstractRebaseliningCommand
11 10
12 11
13 _log = logging.getLogger(__name__) 12 _log = logging.getLogger(__name__)
14 13
15 14
16 class OptimizeBaselines(AbstractRebaseliningCommand): 15 class OptimizeBaselines(AbstractRebaseliningCommand):
17 name = "optimize-baselines" 16 name = "optimize-baselines"
18 help_text = "Reshuffles the baselines for the given tests to use as litte sp ace on disk as possible." 17 help_text = "Reshuffles the baselines for the given tests to use as litte sp ace on disk as possible."
19 show_in_main_help = True 18 show_in_main_help = True
20 argument_names = "TEST_NAMES" 19 argument_names = "TEST_NAMES"
21 20
22 def __init__(self): 21 def __init__(self):
23 super(OptimizeBaselines, self).__init__(options=[ 22 super(OptimizeBaselines, self).__init__(options=[
24 self.suffixes_option, 23 self.suffixes_option,
25 optparse.make_option('--no-modify-scm', action='store_true', default =False,
26 help='Dump SCM commands as JSON instead of actu ally committing changes.'),
27 ] + self.platform_options) 24 ] + self.platform_options)
28 25
29 def _optimize_baseline(self, optimizer, test_name): 26 def _optimize_baseline(self, optimizer, test_name):
30 files_to_delete = [] 27 files_to_delete = []
31 files_to_add = [] 28 files_to_add = []
32 for suffix in self._baseline_suffix_list: 29 for suffix in self._baseline_suffix_list:
33 name = baseline_name(self._tool.filesystem, test_name, suffix) 30 name = baseline_name(self._tool.filesystem, test_name, suffix)
34 succeeded, more_files_to_delete, more_files_to_add = optimizer.optim ize(name) 31 succeeded = optimizer.optimize(name)
35 if not succeeded: 32 if not succeeded:
36 _log.error("Heuristics failed to optimize %s", name) 33 _log.error("Heuristics failed to optimize %s", name)
37 files_to_delete.extend(more_files_to_delete)
38 files_to_add.extend(more_files_to_add)
39 return files_to_delete, files_to_add 34 return files_to_delete, files_to_add
40 35
41 def execute(self, options, args, tool): 36 def execute(self, options, args, tool):
42 self._tool = tool 37 self._tool = tool
43 self._baseline_suffix_list = options.suffixes.split(',') 38 self._baseline_suffix_list = options.suffixes.split(',')
44 port_names = tool.port_factory.all_port_names(options.platform) 39 port_names = tool.port_factory.all_port_names(options.platform)
45 if not port_names: 40 if not port_names:
46 _log.error("No port names match '%s'", options.platform) 41 _log.error("No port names match '%s'", options.platform)
47 return 42 return
48 port = tool.port_factory.get(port_names[0]) 43 port = tool.port_factory.get(port_names[0])
49 optimizer = BaselineOptimizer(tool, port, port_names, skip_scm_commands= options.no_modify_scm) 44 optimizer = BaselineOptimizer(tool, port, port_names)
50 tests = port.tests(args) 45 tests = port.tests(args)
51 for test_name in tests: 46 for test_name in tests:
52 files_to_delete, files_to_add = self._optimize_baseline(optimizer, t est_name) 47 self._optimize_baseline(optimizer, test_name)
53 for path in files_to_delete:
54 self._scm_changes.delete_file(path)
55 for path in files_to_add:
56 self._scm_changes.add_file(path)
57 self._print_scm_changes()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698