| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 _log = logging.getLogger(__name__) | 51 _log = logging.getLogger(__name__) |
| 52 | 52 |
| 53 | 53 |
| 54 # FIXME: Should TestResultWriter know how to compute this string? | 54 # FIXME: Should TestResultWriter know how to compute this string? |
| 55 def _baseline_name(fs, test_name, suffix): | 55 def _baseline_name(fs, test_name, suffix): |
| 56 return fs.splitext(test_name)[0] + TestResultWriter.FILENAME_SUFFIX_EXPECTED
+ "." + suffix | 56 return fs.splitext(test_name)[0] + TestResultWriter.FILENAME_SUFFIX_EXPECTED
+ "." + suffix |
| 57 | 57 |
| 58 | 58 |
| 59 class AbstractRebaseliningCommand(Command): | 59 class AbstractRebaseliningCommand(Command): |
| 60 |
| 60 """Base class for rebaseline-related commands.""" | 61 """Base class for rebaseline-related commands.""" |
| 61 # Not overriding execute() - pylint: disable=abstract-method | 62 # Not overriding execute() - pylint: disable=abstract-method |
| 62 | 63 |
| 63 no_optimize_option = optparse.make_option('--no-optimize', dest='optimize',
action='store_false', default=True, | 64 no_optimize_option = optparse.make_option('--no-optimize', dest='optimize',
action='store_false', default=True, |
| 64 help=('Do not optimize/de-dup the
expectations after rebaselining (default is to de-dup automatically). ' | 65 help=('Do not optimize/de-dup the
expectations after rebaselining (default is to de-dup automatically). ' |
| 65 'You can use "webkit-patch o
ptimize-baselines" to optimize separately.')) | 66 'You can use "webkit-patch o
ptimize-baselines" to optimize separately.')) |
| 66 | 67 |
| 67 platform_options = factory.platform_options(use_globs=True) | 68 platform_options = factory.platform_options(use_globs=True) |
| 68 | 69 |
| 69 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use.") | 70 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use.") |
| 70 | 71 |
| 71 suffixes_option = optparse.make_option("--suffixes", default=','.join(BASELI
NE_SUFFIX_LIST), action="store", | 72 suffixes_option = optparse.make_option("--suffixes", default=','.join(BASELI
NE_SUFFIX_LIST), action="store", |
| 72 help="Comma-separated-list of file ty
pes to rebaseline.") | 73 help="Comma-separated-list of file ty
pes to rebaseline.") |
| 73 | 74 |
| 74 def __init__(self, options=None): | 75 def __init__(self, options=None): |
| 75 super(AbstractRebaseliningCommand, self).__init__(options=options) | 76 super(AbstractRebaseliningCommand, self).__init__(options=options) |
| 76 self._baseline_suffix_list = BASELINE_SUFFIX_LIST | 77 self._baseline_suffix_list = BASELINE_SUFFIX_LIST |
| 77 self._scm_changes = {'add': [], 'delete': [], 'remove-lines': []} | 78 self._scm_changes = {'add': [], 'delete': [], 'remove-lines': []} |
| 78 | 79 |
| 79 def _add_to_scm_later(self, path): | 80 def _add_to_scm_later(self, path): |
| 80 self._scm_changes['add'].append(path) | 81 self._scm_changes['add'].append(path) |
| 81 | 82 |
| 82 def _delete_from_scm_later(self, path): | 83 def _delete_from_scm_later(self, path): |
| 83 self._scm_changes['delete'].append(path) | 84 self._scm_changes['delete'].append(path) |
| 84 | 85 |
| 85 | 86 |
| 86 class BaseInternalRebaselineCommand(AbstractRebaseliningCommand): | 87 class BaseInternalRebaselineCommand(AbstractRebaseliningCommand): |
| 88 |
| 87 """Base class for rebaseline-related commands that are intended to be used b
y other commands.""" | 89 """Base class for rebaseline-related commands that are intended to be used b
y other commands.""" |
| 88 # Not overriding execute() - pylint: disable=abstract-method | 90 # Not overriding execute() - pylint: disable=abstract-method |
| 89 | 91 |
| 90 def __init__(self): | 92 def __init__(self): |
| 91 super(BaseInternalRebaselineCommand, self).__init__(options=[ | 93 super(BaseInternalRebaselineCommand, self).__init__(options=[ |
| 92 self.results_directory_option, | 94 self.results_directory_option, |
| 93 self.suffixes_option, | 95 self.suffixes_option, |
| 94 optparse.make_option("--builder", help="Builder to pull new baseline
s from."), | 96 optparse.make_option("--builder", help="Builder to pull new baseline
s from."), |
| 95 optparse.make_option("--test", help="Test to rebaseline."), | 97 optparse.make_option("--test", help="Test to rebaseline."), |
| 96 ]) | 98 ]) |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 if not port_names: | 317 if not port_names: |
| 316 print "No port names match '%s'" % options.platform | 318 print "No port names match '%s'" % options.platform |
| 317 return | 319 return |
| 318 self._port = tool.port_factory.get(port_names[0]) | 320 self._port = tool.port_factory.get(port_names[0]) |
| 319 self._baseline_optimizer = self._optimizer_class(tool, self._port, port_
names, skip_scm_commands=False) | 321 self._baseline_optimizer = self._optimizer_class(tool, self._port, port_
names, skip_scm_commands=False) |
| 320 for test_name in self._port.tests(args): | 322 for test_name in self._port.tests(args): |
| 321 self._analyze_baseline(options, test_name) | 323 self._analyze_baseline(options, test_name) |
| 322 | 324 |
| 323 | 325 |
| 324 class AbstractParallelRebaselineCommand(AbstractRebaseliningCommand): | 326 class AbstractParallelRebaselineCommand(AbstractRebaseliningCommand): |
| 327 |
| 325 """Base class for rebaseline commands that do some tasks in parallel.""" | 328 """Base class for rebaseline commands that do some tasks in parallel.""" |
| 326 # Not overriding execute() - pylint: disable=abstract-method | 329 # Not overriding execute() - pylint: disable=abstract-method |
| 327 | 330 |
| 328 def __init__(self, options=None): | 331 def __init__(self, options=None): |
| 329 super(AbstractParallelRebaselineCommand, self).__init__(options=options) | 332 super(AbstractParallelRebaselineCommand, self).__init__(options=options) |
| 330 self._builder_data = {} | 333 self._builder_data = {} |
| 331 | 334 |
| 332 def builder_data(self): | 335 def builder_data(self): |
| 333 if not self._builder_data: | 336 if not self._builder_data: |
| 334 for builder_name in self._release_builders(): | 337 for builder_name in self._release_builders(): |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 subprocess_command.append('--verbose') | 834 subprocess_command.append('--verbose') |
| 832 if options.auth_refresh_token_json: | 835 if options.auth_refresh_token_json: |
| 833 subprocess_command.append('--auth-refresh-token-json') | 836 subprocess_command.append('--auth-refresh-token-json') |
| 834 subprocess_command.append(options.auth_refresh_token_json) | 837 subprocess_command.append(options.auth_refresh_token_json) |
| 835 | 838 |
| 836 process = self._tool.executive.popen(subprocess_command, stdout=self._to
ol.executive.PIPE, | 839 process = self._tool.executive.popen(subprocess_command, stdout=self._to
ol.executive.PIPE, |
| 837 stderr=self._tool.executive.STDOUT) | 840 stderr=self._tool.executive.STDOUT) |
| 838 last_output_time = time.time() | 841 last_output_time = time.time() |
| 839 | 842 |
| 840 # git cl sometimes completely hangs. Bail if we haven't gotten any outpu
t to stdout/stderr in a while. | 843 # git cl sometimes completely hangs. Bail if we haven't gotten any outpu
t to stdout/stderr in a while. |
| 841 while process.poll() == None and time.time() < last_output_time + self.S
ECONDS_BEFORE_GIVING_UP: | 844 while process.poll() is None and time.time() < last_output_time + self.S
ECONDS_BEFORE_GIVING_UP: |
| 842 # FIXME: This doesn't make any sense. readline blocks, so all this c
ode to | 845 # FIXME: This doesn't make any sense. readline blocks, so all this c
ode to |
| 843 # try and bail is useless. Instead, we should do the readline calls
on a | 846 # try and bail is useless. Instead, we should do the readline calls
on a |
| 844 # subthread. Then the rest of this code would make sense. | 847 # subthread. Then the rest of this code would make sense. |
| 845 out = process.stdout.readline().rstrip('\n') | 848 out = process.stdout.readline().rstrip('\n') |
| 846 if out: | 849 if out: |
| 847 last_output_time = time.time() | 850 last_output_time = time.time() |
| 848 _log.info(out) | 851 _log.info(out) |
| 849 | 852 |
| 850 if process.poll() == None: | 853 if process.poll() is None: |
| 851 _log.error('Command hung: %s' % subprocess_command) | 854 _log.error('Command hung: %s' % subprocess_command) |
| 852 return False | 855 return False |
| 853 return True | 856 return True |
| 854 | 857 |
| 855 # FIXME: Move this somewhere more general. | 858 # FIXME: Move this somewhere more general. |
| 856 def tree_status(self): | 859 def tree_status(self): |
| 857 blink_tree_status_url = "http://chromium-status.appspot.com/status" | 860 blink_tree_status_url = "http://chromium-status.appspot.com/status" |
| 858 status = urllib2.urlopen(blink_tree_status_url).read().lower() | 861 status = urllib2.urlopen(blink_tree_status_url).read().lower() |
| 859 if 'closed' in status or status == "0": | 862 if 'closed' in status or status == "0": |
| 860 return 'closed' | 863 return 'closed' |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 issue_already_closed = tool.executive.run_command( | 944 issue_already_closed = tool.executive.run_command( |
| 942 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], | 945 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], |
| 943 return_exit_code=True) | 946 return_exit_code=True) |
| 944 if not issue_already_closed: | 947 if not issue_already_closed: |
| 945 self._run_git_cl_command(options, ['set_close']) | 948 self._run_git_cl_command(options, ['set_close']) |
| 946 | 949 |
| 947 tool.scm().ensure_cleanly_tracking_remote_master() | 950 tool.scm().ensure_cleanly_tracking_remote_master() |
| 948 if old_branch_name_or_ref: | 951 if old_branch_name_or_ref: |
| 949 tool.scm().checkout_branch(old_branch_name_or_ref) | 952 tool.scm().checkout_branch(old_branch_name_or_ref) |
| 950 tool.scm().delete_branch(rebaseline_branch_name) | 953 tool.scm().delete_branch(rebaseline_branch_name) |
| OLD | NEW |