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, build_number=None): | |
73 builder = self._tool.buildbot.builder_with_name(builder_name) | |
74 if build_number: | |
75 build = builder.build(build_number) | |
76 return build.results_url() | |
77 return builder.latest_layout_test_results_url() | |
78 | |
79 def _add_to_scm_later(self, path): | 72 def _add_to_scm_later(self, path): |
80 self._scm_changes['add'].append(path) | 73 self._scm_changes['add'].append(path) |
81 | 74 |
82 def _delete_from_scm_later(self, path): | 75 def _delete_from_scm_later(self, path): |
83 self._scm_changes['delete'].append(path) | 76 self._scm_changes['delete'].append(path) |
84 | 77 |
85 def _print_scm_changes(self): | 78 def _print_scm_changes(self): |
86 print(json.dumps(self._scm_changes)) | 79 print(json.dumps(self._scm_changes)) |
87 | 80 |
88 | 81 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 port = self._tool.port_factory.get_from_builder_name(options.builder) | 211 port = self._tool.port_factory.get_from_builder_name(options.builder) |
219 if port.reference_files(options.test): | 212 if port.reference_files(options.test): |
220 if 'png' in self._baseline_suffix_list: | 213 if 'png' in self._baseline_suffix_list: |
221 _log.warning("Cannot rebaseline image result for reftest: %s", o
ptions.test) | 214 _log.warning("Cannot rebaseline image result for reftest: %s", o
ptions.test) |
222 return | 215 return |
223 assert self._baseline_suffix_list == ['txt'] | 216 assert self._baseline_suffix_list == ['txt'] |
224 | 217 |
225 if options.results_directory: | 218 if options.results_directory: |
226 results_url = 'file://' + options.results_directory | 219 results_url = 'file://' + options.results_directory |
227 else: | 220 else: |
228 results_url = self._results_url(options.builder, build_number=option
s.build_number) | 221 results_url = self._tool.buildbot.results_url(options.builder, build
_number=options.build_number) |
229 | 222 |
230 for suffix in self._baseline_suffix_list: | 223 for suffix in self._baseline_suffix_list: |
231 self._rebaseline_test(options.builder, options.test, suffix, results
_url) | 224 self._rebaseline_test(options.builder, options.test, suffix, results
_url) |
232 self._scm_changes['remove-lines'].append({'builder': options.builder, 't
est': options.test}) | 225 self._scm_changes['remove-lines'].append({'builder': options.builder, 't
est': options.test}) |
233 | 226 |
234 def execute(self, options, args, tool): | 227 def execute(self, options, args, tool): |
235 self._rebaseline_test_and_update_expectations(options) | 228 self._rebaseline_test_and_update_expectations(options) |
236 self._print_scm_changes() | 229 self._print_scm_changes() |
237 | 230 |
238 | 231 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 """Base class for rebaseline commands that do some tasks in parallel.""" | 276 """Base class for rebaseline commands that do some tasks in parallel.""" |
284 # Not overriding execute() - pylint: disable=abstract-method | 277 # Not overriding execute() - pylint: disable=abstract-method |
285 | 278 |
286 def __init__(self, options=None): | 279 def __init__(self, options=None): |
287 super(AbstractParallelRebaselineCommand, self).__init__(options=options) | 280 super(AbstractParallelRebaselineCommand, self).__init__(options=options) |
288 | 281 |
289 @memoized | 282 @memoized |
290 def builder_data(self): | 283 def builder_data(self): |
291 builder_to_results = {} | 284 builder_to_results = {} |
292 for builder_name in self._release_builders(): | 285 for builder_name in self._release_builders(): |
293 builder = self._tool.buildbot.builder_with_name(builder_name) | 286 builder_results = self._tool.buildbot.accumulated_results_url_base(b
uilder_name) |
294 builder_results = builder.latest_layout_test_results() | |
295 if builder_results: | 287 if builder_results: |
296 builder_to_results[builder_name] = builder_results | 288 builder_to_results[builder_name] = builder_results |
297 else: | 289 else: |
298 raise Exception("No result for builder %s." % builder_name) | 290 raise Exception("No result for builder %s." % builder_name) |
299 return builder_to_results | 291 return builder_to_results |
300 | 292 |
301 # The release builders cycle much faster than the debug ones and cover all t
he platforms. | 293 # The release builders cycle much faster than the debug ones and cover all t
he platforms. |
302 def _release_builders(self): | 294 def _release_builders(self): |
303 release_builders = [] | 295 release_builders = [] |
304 for builder_name in self._tool.builders.all_continuous_builder_names(): | 296 for builder_name in self._tool.builders.all_continuous_builder_names(): |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 super(Rebaseline, self).__init__(options=[ | 617 super(Rebaseline, self).__init__(options=[ |
626 self.no_optimize_option, | 618 self.no_optimize_option, |
627 # FIXME: should we support the platform options in addition to (or i
nstead of) --builders? | 619 # FIXME: should we support the platform options in addition to (or i
nstead of) --builders? |
628 self.suffixes_option, | 620 self.suffixes_option, |
629 self.results_directory_option, | 621 self.results_directory_option, |
630 optparse.make_option("--builders", default=None, action="append", | 622 optparse.make_option("--builders", default=None, action="append", |
631 help="Comma-separated-list of builders to pull
new baselines from (can also be provided multiple times)."), | 623 help="Comma-separated-list of builders to pull
new baselines from (can also be provided multiple times)."), |
632 ]) | 624 ]) |
633 | 625 |
634 def _builders_to_pull_from(self): | 626 def _builders_to_pull_from(self): |
635 chosen_names = self._tool.user.prompt_with_list( | 627 return self._tool.user.prompt_with_list( |
636 "Which builder to pull results from:", self._release_builders(), can
_choose_multiple=True) | 628 "Which builder to pull results from:", self._release_builders(), can
_choose_multiple=True) |
637 return [self._builder_with_name(name) for name in chosen_names] | |
638 | |
639 def _builder_with_name(self, name): | |
640 return self._tool.buildbot.builder_with_name(name) | |
641 | 629 |
642 def execute(self, options, args, tool): | 630 def execute(self, options, args, tool): |
643 if not args: | 631 if not args: |
644 _log.error("Must list tests to rebaseline.") | 632 _log.error("Must list tests to rebaseline.") |
645 return | 633 return |
646 | 634 |
647 if options.builders: | 635 if options.builders: |
648 builders_to_check = [] | 636 builders_to_check = [] |
649 for builder_names in options.builders: | 637 for builder_names in options.builders: |
650 builders_to_check += [self._builder_with_name(name) for name in
builder_names.split(",")] | 638 builders_to_check += builder_names.split(",") |
651 else: | 639 else: |
652 builders_to_check = self._builders_to_pull_from() | 640 builders_to_check = self._builders_to_pull_from() |
653 | 641 |
654 test_prefix_list = {} | 642 test_prefix_list = {} |
655 suffixes_to_update = options.suffixes.split(",") | 643 suffixes_to_update = options.suffixes.split(",") |
656 | 644 |
657 for builder in builders_to_check: | 645 for builder in builders_to_check: |
658 for test in args: | 646 for test in args: |
659 if test not in test_prefix_list: | 647 if test not in test_prefix_list: |
660 test_prefix_list[test] = {} | 648 test_prefix_list[test] = {} |
661 test_prefix_list[test][builder.name()] = suffixes_to_update | 649 test_prefix_list[test][builder] = suffixes_to_update |
662 | 650 |
663 if options.verbose: | 651 if options.verbose: |
664 _log.debug("rebaseline-json: " + str(test_prefix_list)) | 652 _log.debug("rebaseline-json: " + str(test_prefix_list)) |
665 | 653 |
666 self._rebaseline(options, test_prefix_list) | 654 self._rebaseline(options, test_prefix_list) |
667 | 655 |
668 | 656 |
669 class AutoRebaseline(AbstractParallelRebaselineCommand): | 657 class AutoRebaseline(AbstractParallelRebaselineCommand): |
670 name = "auto-rebaseline" | 658 name = "auto-rebaseline" |
671 help_text = "Rebaselines any NeedsRebaseline lines in TestExpectations that
have cycled through all the bots." | 659 help_text = "Rebaselines any NeedsRebaseline lines in TestExpectations that
have cycled through all the bots." |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 issue_already_closed = tool.executive.run_command( | 913 issue_already_closed = tool.executive.run_command( |
926 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], | 914 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], |
927 return_exit_code=True) | 915 return_exit_code=True) |
928 if not issue_already_closed: | 916 if not issue_already_closed: |
929 self._run_git_cl_command(options, ['set_close']) | 917 self._run_git_cl_command(options, ['set_close']) |
930 | 918 |
931 tool.scm().ensure_cleanly_tracking_remote_master() | 919 tool.scm().ensure_cleanly_tracking_remote_master() |
932 if old_branch_name_or_ref: | 920 if old_branch_name_or_ref: |
933 tool.scm().checkout_branch(old_branch_name_or_ref) | 921 tool.scm().checkout_branch(old_branch_name_or_ref) |
934 tool.scm().delete_branch(rebaseline_branch_name) | 922 tool.scm().delete_branch(rebaseline_branch_name) |
OLD | NEW |