OLD | NEW |
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 |
(...skipping 20 matching lines...) Expand all Loading... |
31 import optparse | 31 import optparse |
32 import re | 32 import re |
33 import sys | 33 import sys |
34 import time | 34 import time |
35 import traceback | 35 import traceback |
36 import urllib2 | 36 import urllib2 |
37 | 37 |
38 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer | 38 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer |
39 from webkitpy.common.memoized import memoized | 39 from webkitpy.common.memoized import memoized |
40 from webkitpy.common.system.executive import ScriptError | 40 from webkitpy.common.system.executive import ScriptError |
41 from webkitpy.layout_tests.controllers.test_result_writer import TestResultWrite
r | 41 from webkitpy.layout_tests.controllers.test_result_writer import baseline_name |
42 from webkitpy.layout_tests.models.test_expectations import TestExpectations, BAS
ELINE_SUFFIX_LIST, SKIP | 42 from webkitpy.layout_tests.models.test_expectations import TestExpectations, BAS
ELINE_SUFFIX_LIST, SKIP |
43 from webkitpy.layout_tests.port import factory | 43 from webkitpy.layout_tests.port import factory |
44 from webkitpy.tool.commands.command import Command | 44 from webkitpy.tool.commands.command import Command |
45 | 45 |
46 | 46 |
47 _log = logging.getLogger(__name__) | 47 _log = logging.getLogger(__name__) |
48 | 48 |
49 | 49 |
50 # FIXME: Should TestResultWriter know how to compute this string? | |
51 def _baseline_name(fs, test_name, suffix): | |
52 return fs.splitext(test_name)[0] + TestResultWriter.FILENAME_SUFFIX_EXPECTED
+ "." + suffix | |
53 | |
54 | |
55 class AbstractRebaseliningCommand(Command): | 50 class AbstractRebaseliningCommand(Command): |
56 """Base class for rebaseline-related commands.""" | 51 """Base class for rebaseline-related commands.""" |
57 # Not overriding execute() - pylint: disable=abstract-method | 52 # Not overriding execute() - pylint: disable=abstract-method |
58 | 53 |
59 no_optimize_option = optparse.make_option('--no-optimize', dest='optimize',
action='store_false', default=True, | 54 no_optimize_option = optparse.make_option('--no-optimize', dest='optimize',
action='store_false', default=True, |
60 help=('Do not optimize/de-dup the
expectations after rebaselining (default is to de-dup automatically). ' | 55 help=('Do not optimize/de-dup the
expectations after rebaselining (default is to de-dup automatically). ' |
61 'You can use "webkit-patch o
ptimize-baselines" to optimize separately.')) | 56 'You can use "webkit-patch o
ptimize-baselines" to optimize separately.')) |
62 | 57 |
63 platform_options = factory.platform_options(use_globs=True) | 58 platform_options = factory.platform_options(use_globs=True) |
64 | 59 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 super(OptimizeBaselines, self).__init__(options=[ | 235 super(OptimizeBaselines, self).__init__(options=[ |
241 self.suffixes_option, | 236 self.suffixes_option, |
242 optparse.make_option('--no-modify-scm', action='store_true', default
=False, | 237 optparse.make_option('--no-modify-scm', action='store_true', default
=False, |
243 help='Dump SCM commands as JSON instead of actu
ally committing changes.'), | 238 help='Dump SCM commands as JSON instead of actu
ally committing changes.'), |
244 ] + self.platform_options) | 239 ] + self.platform_options) |
245 | 240 |
246 def _optimize_baseline(self, optimizer, test_name): | 241 def _optimize_baseline(self, optimizer, test_name): |
247 files_to_delete = [] | 242 files_to_delete = [] |
248 files_to_add = [] | 243 files_to_add = [] |
249 for suffix in self._baseline_suffix_list: | 244 for suffix in self._baseline_suffix_list: |
250 baseline_name = _baseline_name(self._tool.filesystem, test_name, suf
fix) | 245 name = baseline_name(self._tool.filesystem, test_name, suffix) |
251 succeeded, more_files_to_delete, more_files_to_add = optimizer.optim
ize(baseline_name) | 246 succeeded, more_files_to_delete, more_files_to_add = optimizer.optim
ize(name) |
252 if not succeeded: | 247 if not succeeded: |
253 print "Heuristics failed to optimize %s" % baseline_name | 248 _log.error("Heuristics failed to optimize %s", name) |
254 files_to_delete.extend(more_files_to_delete) | 249 files_to_delete.extend(more_files_to_delete) |
255 files_to_add.extend(more_files_to_add) | 250 files_to_add.extend(more_files_to_add) |
256 return files_to_delete, files_to_add | 251 return files_to_delete, files_to_add |
257 | 252 |
258 def execute(self, options, args, tool): | 253 def execute(self, options, args, tool): |
259 self._baseline_suffix_list = options.suffixes.split(',') | 254 self._baseline_suffix_list = options.suffixes.split(',') |
260 port_names = tool.port_factory.all_port_names(options.platform) | 255 port_names = tool.port_factory.all_port_names(options.platform) |
261 if not port_names: | 256 if not port_names: |
262 print "No port names match '%s'" % options.platform | 257 _log.error("No port names match '%s'", options.platform) |
263 return | 258 return |
264 port = tool.port_factory.get(port_names[0]) | 259 port = tool.port_factory.get(port_names[0]) |
265 optimizer = BaselineOptimizer(tool, port, port_names, skip_scm_commands=
options.no_modify_scm) | 260 optimizer = BaselineOptimizer(tool, port, port_names, skip_scm_commands=
options.no_modify_scm) |
266 tests = port.tests(args) | 261 tests = port.tests(args) |
267 for test_name in tests: | 262 for test_name in tests: |
268 files_to_delete, files_to_add = self._optimize_baseline(optimizer, t
est_name) | 263 files_to_delete, files_to_add = self._optimize_baseline(optimizer, t
est_name) |
269 for path in files_to_delete: | 264 for path in files_to_delete: |
270 self._delete_from_scm_later(path) | 265 self._delete_from_scm_later(path) |
271 for path in files_to_add: | 266 for path in files_to_add: |
272 self._add_to_scm_later(path) | 267 self._add_to_scm_later(path) |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 issue_already_closed = tool.executive.run_command( | 889 issue_already_closed = tool.executive.run_command( |
895 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], | 890 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], |
896 return_exit_code=True) | 891 return_exit_code=True) |
897 if not issue_already_closed: | 892 if not issue_already_closed: |
898 self._run_git_cl_command(options, ['set_close']) | 893 self._run_git_cl_command(options, ['set_close']) |
899 | 894 |
900 tool.scm().ensure_cleanly_tracking_remote_master() | 895 tool.scm().ensure_cleanly_tracking_remote_master() |
901 if old_branch_name_or_ref: | 896 if old_branch_name_or_ref: |
902 tool.scm().checkout_branch(old_branch_name_or_ref) | 897 tool.scm().checkout_branch(old_branch_name_or_ref) |
903 tool.scm().delete_branch(rebaseline_branch_name) | 898 tool.scm().delete_branch(rebaseline_branch_name) |
OLD | NEW |