| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 | 185 |
| 186 class RebaselineTest(BaseInternalRebaselineCommand): | 186 class RebaselineTest(BaseInternalRebaselineCommand): |
| 187 name = "rebaseline-test-internal" | 187 name = "rebaseline-test-internal" |
| 188 help_text = "Rebaseline a single test from a buildbot. Only intended for use
by other webkit-patch commands." | 188 help_text = "Rebaseline a single test from a buildbot. Only intended for use
by other webkit-patch commands." |
| 189 | 189 |
| 190 def _results_url(self, builder_name): | 190 def _results_url(self, builder_name): |
| 191 return self._tool.buildbot.builder_with_name(builder_name).latest_layout
_test_results_url() | 191 return self._tool.buildbot.builder_with_name(builder_name).latest_layout
_test_results_url() |
| 192 | 192 |
| 193 def _save_baseline(self, data, target_baseline, baseline_directory, test_nam
e, suffix): | 193 def _save_baseline(self, data, target_baseline, baseline_directory, test_nam
e, suffix): |
| 194 _log.debug('Calling _save_baseline(%r, %r, %r, %r, %r)', data, target_ba
seline, baseline_directory, test_name, suffix) |
| 194 if not data: | 195 if not data: |
| 195 _log.debug("No baseline data to save.") | 196 _log.debug("No baseline data to save.") |
| 196 return | 197 return |
| 197 | 198 |
| 198 filesystem = self._tool.filesystem | 199 filesystem = self._tool.filesystem |
| 199 filesystem.maybe_make_directory(filesystem.dirname(target_baseline)) | 200 filesystem.maybe_make_directory(filesystem.dirname(target_baseline)) |
| 200 filesystem.write_binary_file(target_baseline, data) | 201 filesystem.write_binary_file(target_baseline, data) |
| 201 if not self._tool.scm().exists(target_baseline): | 202 if not self._tool.scm().exists(target_baseline): |
| 202 self._add_to_scm_later(target_baseline) | 203 self._add_to_scm_later(target_baseline) |
| 203 | 204 |
| 204 def _rebaseline_test(self, builder_name, test_name, suffix, results_url): | 205 def _rebaseline_test(self, builder_name, test_name, suffix, results_url): |
| 205 baseline_directory = self._baseline_directory(builder_name) | 206 baseline_directory = self._baseline_directory(builder_name) |
| 206 | 207 |
| 207 source_baseline = "%s/%s" % (results_url, self._file_name_for_actual_res
ult(test_name, suffix)) | 208 source_baseline = "%s/%s" % (results_url, self._file_name_for_actual_res
ult(test_name, suffix)) |
| 208 target_baseline = self._tool.filesystem.join(baseline_directory, self._f
ile_name_for_expected_result(test_name, suffix)) | 209 target_baseline = self._tool.filesystem.join(baseline_directory, self._f
ile_name_for_expected_result(test_name, suffix)) |
| 209 | 210 |
| 210 _log.debug("Retrieving %s." % source_baseline) | 211 _log.debug("Retrieving %s." % source_baseline) |
| 211 self._save_baseline(self._tool.web.get_binary(source_baseline, convert_4
04_to_None=True), | 212 try: |
| 212 target_baseline, baseline_directory, test_name, suff
ix) | 213 data = self._tool.web.get_binary(source_baseline, convert_404_to_Non
e=True) |
| 214 except urllib2.URLError: |
| 215 data = None |
| 216 self._save_baseline(data, target_baseline, baseline_directory, test_name
, suffix) |
| 213 | 217 |
| 214 def _rebaseline_test_and_update_expectations(self, options): | 218 def _rebaseline_test_and_update_expectations(self, options): |
| 215 self._baseline_suffix_list = options.suffixes.split(',') | 219 self._baseline_suffix_list = options.suffixes.split(',') |
| 216 | 220 |
| 217 port = self._tool.port_factory.get_from_builder_name(options.builder) | 221 port = self._tool.port_factory.get_from_builder_name(options.builder) |
| 218 if port.reference_files(options.test): | 222 if port.reference_files(options.test): |
| 219 if 'png' in self._baseline_suffix_list: | 223 if 'png' in self._baseline_suffix_list: |
| 220 _log.warning("Cannot rebaseline image result for reftest: %s", o
ptions.test) | 224 _log.warning("Cannot rebaseline image result for reftest: %s", o
ptions.test) |
| 221 return | 225 return |
| 222 assert self._baseline_suffix_list == ['txt'] | 226 assert self._baseline_suffix_list == ['txt'] |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 issue_already_closed = tool.executive.run_command( | 936 issue_already_closed = tool.executive.run_command( |
| 933 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], | 937 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], |
| 934 return_exit_code=True) | 938 return_exit_code=True) |
| 935 if not issue_already_closed: | 939 if not issue_already_closed: |
| 936 self._run_git_cl_command(options, ['set_close']) | 940 self._run_git_cl_command(options, ['set_close']) |
| 937 | 941 |
| 938 tool.scm().ensure_cleanly_tracking_remote_master() | 942 tool.scm().ensure_cleanly_tracking_remote_master() |
| 939 if old_branch_name_or_ref: | 943 if old_branch_name_or_ref: |
| 940 tool.scm().checkout_branch(old_branch_name_or_ref) | 944 tool.scm().checkout_branch(old_branch_name_or_ref) |
| 941 tool.scm().delete_branch(rebaseline_branch_name) | 945 tool.scm().delete_branch(rebaseline_branch_name) |
| OLD | NEW |