| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use.") | 62 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use.") |
| 63 | 63 |
| 64 suffixes_option = optparse.make_option("--suffixes", default=','.join(BASELI
NE_SUFFIX_LIST), action="store", | 64 suffixes_option = optparse.make_option("--suffixes", default=','.join(BASELI
NE_SUFFIX_LIST), action="store", |
| 65 help="Comma-separated-list of file ty
pes to rebaseline.") | 65 help="Comma-separated-list of file ty
pes to rebaseline.") |
| 66 | 66 |
| 67 def __init__(self, options=None): | 67 def __init__(self, options=None): |
| 68 super(AbstractRebaseliningCommand, self).__init__(options=options) | 68 super(AbstractRebaseliningCommand, self).__init__(options=options) |
| 69 self._baseline_suffix_list = BASELINE_SUFFIX_LIST | 69 self._baseline_suffix_list = BASELINE_SUFFIX_LIST |
| 70 self._scm_changes = {'add': [], 'delete': [], 'remove-lines': []} | 70 self._scm_changes = {'add': [], 'delete': [], 'remove-lines': []} |
| 71 | 71 |
| 72 def _results_url(self, builder_name, master_name, build_number=None): | 72 def _results_url(self, builder_name, build_number=None): |
| 73 builder = self._tool.buildbot.builder_with_name(builder_name, master_nam
e) | 73 builder = self._tool.buildbot.builder_with_name(builder_name) |
| 74 if build_number: | 74 if build_number: |
| 75 build = builder.build(build_number) | 75 build = builder.build(build_number) |
| 76 return build.results_url() | 76 return build.results_url() |
| 77 return builder.latest_layout_test_results_url() | 77 return builder.latest_layout_test_results_url() |
| 78 | 78 |
| 79 def _add_to_scm_later(self, path): | 79 def _add_to_scm_later(self, path): |
| 80 self._scm_changes['add'].append(path) | 80 self._scm_changes['add'].append(path) |
| 81 | 81 |
| 82 def _delete_from_scm_later(self, path): | 82 def _delete_from_scm_later(self, path): |
| 83 self._scm_changes['delete'].append(path) | 83 self._scm_changes['delete'].append(path) |
| 84 | 84 |
| 85 def _print_scm_changes(self): | 85 def _print_scm_changes(self): |
| 86 print(json.dumps(self._scm_changes)) | 86 print(json.dumps(self._scm_changes)) |
| 87 | 87 |
| 88 | 88 |
| 89 class BaseInternalRebaselineCommand(AbstractRebaseliningCommand): | 89 class BaseInternalRebaselineCommand(AbstractRebaseliningCommand): |
| 90 """Base class for rebaseline-related commands that are intended to be used b
y other commands.""" | 90 """Base class for rebaseline-related commands that are intended to be used b
y other commands.""" |
| 91 # Not overriding execute() - pylint: disable=abstract-method | 91 # Not overriding execute() - pylint: disable=abstract-method |
| 92 | 92 |
| 93 def __init__(self): | 93 def __init__(self): |
| 94 super(BaseInternalRebaselineCommand, self).__init__(options=[ | 94 super(BaseInternalRebaselineCommand, self).__init__(options=[ |
| 95 self.results_directory_option, | 95 self.results_directory_option, |
| 96 self.suffixes_option, | 96 self.suffixes_option, |
| 97 optparse.make_option("--builder", help="Builder to pull new baseline
s from."), | 97 optparse.make_option("--builder", help="Builder to pull new baseline
s from."), |
| 98 optparse.make_option("--test", help="Test to rebaseline."), | 98 optparse.make_option("--test", help="Test to rebaseline."), |
| 99 optparse.make_option("--build-number", default=None, type="int", | 99 optparse.make_option("--build-number", default=None, type="int", |
| 100 help="Optional build number; if not given, the
latest build is used."), | 100 help="Optional build number; if not given, the
latest build is used."), |
| 101 optparse.make_option("--master-name", default='chromium.webkit', typ
e="str", | |
| 102 help="Optional master name; if not given, a def
ault master will be used."), | |
| 103 ]) | 101 ]) |
| 104 | 102 |
| 105 def _baseline_directory(self, builder_name): | 103 def _baseline_directory(self, builder_name): |
| 106 port = self._tool.port_factory.get_from_builder_name(builder_name) | 104 port = self._tool.port_factory.get_from_builder_name(builder_name) |
| 107 return port.baseline_version_dir() | 105 return port.baseline_version_dir() |
| 108 | 106 |
| 109 def _test_root(self, test_name): | 107 def _test_root(self, test_name): |
| 110 return self._tool.filesystem.splitext(test_name)[0] | 108 return self._tool.filesystem.splitext(test_name)[0] |
| 111 | 109 |
| 112 def _file_name_for_actual_result(self, test_name, suffix): | 110 def _file_name_for_actual_result(self, test_name, suffix): |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 port = self._tool.port_factory.get_from_builder_name(options.builder) | 218 port = self._tool.port_factory.get_from_builder_name(options.builder) |
| 221 if port.reference_files(options.test): | 219 if port.reference_files(options.test): |
| 222 if 'png' in self._baseline_suffix_list: | 220 if 'png' in self._baseline_suffix_list: |
| 223 _log.warning("Cannot rebaseline image result for reftest: %s", o
ptions.test) | 221 _log.warning("Cannot rebaseline image result for reftest: %s", o
ptions.test) |
| 224 return | 222 return |
| 225 assert self._baseline_suffix_list == ['txt'] | 223 assert self._baseline_suffix_list == ['txt'] |
| 226 | 224 |
| 227 if options.results_directory: | 225 if options.results_directory: |
| 228 results_url = 'file://' + options.results_directory | 226 results_url = 'file://' + options.results_directory |
| 229 else: | 227 else: |
| 230 results_url = self._results_url(options.builder, options.master_name
, build_number=options.build_number) | 228 results_url = self._results_url(options.builder, build_number=option
s.build_number) |
| 231 | 229 |
| 232 for suffix in self._baseline_suffix_list: | 230 for suffix in self._baseline_suffix_list: |
| 233 self._rebaseline_test(options.builder, options.test, suffix, results
_url) | 231 self._rebaseline_test(options.builder, options.test, suffix, results
_url) |
| 234 self._scm_changes['remove-lines'].append({'builder': options.builder, 't
est': options.test}) | 232 self._scm_changes['remove-lines'].append({'builder': options.builder, 't
est': options.test}) |
| 235 | 233 |
| 236 def execute(self, options, args, tool): | 234 def execute(self, options, args, tool): |
| 237 self._rebaseline_test_and_update_expectations(options) | 235 self._rebaseline_test_and_update_expectations(options) |
| 238 self._print_scm_changes() | 236 self._print_scm_changes() |
| 239 | 237 |
| 240 | 238 |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 issue_already_closed = tool.executive.run_command( | 915 issue_already_closed = tool.executive.run_command( |
| 918 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], | 916 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], |
| 919 return_exit_code=True) | 917 return_exit_code=True) |
| 920 if not issue_already_closed: | 918 if not issue_already_closed: |
| 921 self._run_git_cl_command(options, ['set_close']) | 919 self._run_git_cl_command(options, ['set_close']) |
| 922 | 920 |
| 923 tool.scm().ensure_cleanly_tracking_remote_master() | 921 tool.scm().ensure_cleanly_tracking_remote_master() |
| 924 if old_branch_name_or_ref: | 922 if old_branch_name_or_ref: |
| 925 tool.scm().checkout_branch(old_branch_name_or_ref) | 923 tool.scm().checkout_branch(old_branch_name_or_ref) |
| 926 tool.scm().delete_branch(rebaseline_branch_name) | 924 tool.scm().delete_branch(rebaseline_branch_name) |
| OLD | NEW |