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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use.") | 89 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use.") |
90 | 90 |
91 suffixes_option = optparse.make_option("--suffixes", default=','.join(BASELI
NE_SUFFIX_LIST), action="store", | 91 suffixes_option = optparse.make_option("--suffixes", default=','.join(BASELI
NE_SUFFIX_LIST), action="store", |
92 help="Comma-separated-list of file ty
pes to rebaseline.") | 92 help="Comma-separated-list of file ty
pes to rebaseline.") |
93 | 93 |
94 def __init__(self, options=None): | 94 def __init__(self, options=None): |
95 super(AbstractRebaseliningCommand, self).__init__(options=options) | 95 super(AbstractRebaseliningCommand, self).__init__(options=options) |
96 self._baseline_suffix_list = BASELINE_SUFFIX_LIST | 96 self._baseline_suffix_list = BASELINE_SUFFIX_LIST |
97 self._scm_changes = {'add': [], 'delete': [], 'remove-lines': []} | 97 self._scm_changes = {'add': [], 'delete': [], 'remove-lines': []} |
98 | 98 |
99 def _results_url(self, builder_name, build_number=None): | |
100 builder = self._tool.buildbot.builder_with_name(builder_name) | |
101 if build_number: | |
102 build = builder.build(build_number) | |
103 return build.results_url() | |
104 return builder.latest_layout_test_results_url() | |
105 | |
106 def _add_to_scm_later(self, path): | 99 def _add_to_scm_later(self, path): |
107 self._scm_changes['add'].append(path) | 100 self._scm_changes['add'].append(path) |
108 | 101 |
109 def _delete_from_scm_later(self, path): | 102 def _delete_from_scm_later(self, path): |
110 self._scm_changes['delete'].append(path) | 103 self._scm_changes['delete'].append(path) |
111 | 104 |
112 def _print_scm_changes(self): | 105 def _print_scm_changes(self): |
113 print(json.dumps(self._scm_changes)) | 106 print(json.dumps(self._scm_changes)) |
114 | 107 |
115 | 108 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 port = self._tool.port_factory.get_from_builder_name(options.builder) | 238 port = self._tool.port_factory.get_from_builder_name(options.builder) |
246 if port.reference_files(options.test): | 239 if port.reference_files(options.test): |
247 if 'png' in self._baseline_suffix_list: | 240 if 'png' in self._baseline_suffix_list: |
248 _log.warning("Cannot rebaseline image result for reftest: %s", o
ptions.test) | 241 _log.warning("Cannot rebaseline image result for reftest: %s", o
ptions.test) |
249 return | 242 return |
250 assert self._baseline_suffix_list == ['txt'] | 243 assert self._baseline_suffix_list == ['txt'] |
251 | 244 |
252 if options.results_directory: | 245 if options.results_directory: |
253 results_url = 'file://' + options.results_directory | 246 results_url = 'file://' + options.results_directory |
254 else: | 247 else: |
255 results_url = self._results_url(options.builder, build_number=option
s.build_number) | 248 results_url = self._tool.buildbot.results_url(options.builder, build
_number=options.build_number) |
256 | 249 |
257 for suffix in self._baseline_suffix_list: | 250 for suffix in self._baseline_suffix_list: |
258 self._rebaseline_test(options.builder, options.test, suffix, results
_url) | 251 self._rebaseline_test(options.builder, options.test, suffix, results
_url) |
259 self._scm_changes['remove-lines'].append({'builder': options.builder, 't
est': options.test}) | 252 self._scm_changes['remove-lines'].append({'builder': options.builder, 't
est': options.test}) |
260 | 253 |
261 def execute(self, options, args, tool): | 254 def execute(self, options, args, tool): |
262 self._rebaseline_test_and_update_expectations(options) | 255 self._rebaseline_test_and_update_expectations(options) |
263 self._print_scm_changes() | 256 self._print_scm_changes() |
264 | 257 |
265 | 258 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 @memoized | 309 @memoized |
317 def build_data(self): | 310 def build_data(self): |
318 """Returns a map of Build objects to LayoutTestResult objects. | 311 """Returns a map of Build objects to LayoutTestResult objects. |
319 | 312 |
320 The Build objects are the latest builds for the release builders, | 313 The Build objects are the latest builds for the release builders, |
321 and LayoutTestResult objects for results fetched from archived layout | 314 and LayoutTestResult objects for results fetched from archived layout |
322 test results. | 315 test results. |
323 """ | 316 """ |
324 build_to_results = {} | 317 build_to_results = {} |
325 for builder_name in self._release_builders(): | 318 for builder_name in self._release_builders(): |
326 builder = self._tool.buildbot.builder_with_name(builder_name) | 319 builder_results = self._tool.buildbot.accumulated_results_url_base(b
uilder_name) |
327 builder_results = builder.latest_layout_test_results() | |
328 if builder_results: | 320 if builder_results: |
329 build_to_results[Build(builder_name)] = builder_results | 321 build_to_results[Build(builder_name)] = builder_results |
330 else: | 322 else: |
331 raise Exception("No result for builder %s." % builder_name) | 323 raise Exception("No result for builder %s." % builder_name) |
332 return build_to_results | 324 return build_to_results |
333 | 325 |
334 # The release builders cycle much faster than the debug ones and cover all t
he platforms. | 326 # The release builders cycle much faster than the debug ones and cover all t
he platforms. |
335 def _release_builders(self): | 327 def _release_builders(self): |
336 release_builders = [] | 328 release_builders = [] |
337 for builder_name in self._tool.builders.all_continuous_builder_names(): | 329 for builder_name in self._tool.builders.all_continuous_builder_names(): |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 super(Rebaseline, self).__init__(options=[ | 678 super(Rebaseline, self).__init__(options=[ |
687 self.no_optimize_option, | 679 self.no_optimize_option, |
688 # FIXME: should we support the platform options in addition to (or i
nstead of) --builders? | 680 # FIXME: should we support the platform options in addition to (or i
nstead of) --builders? |
689 self.suffixes_option, | 681 self.suffixes_option, |
690 self.results_directory_option, | 682 self.results_directory_option, |
691 optparse.make_option("--builders", default=None, action="append", | 683 optparse.make_option("--builders", default=None, action="append", |
692 help="Comma-separated-list of builders to pull
new baselines from (can also be provided multiple times)."), | 684 help="Comma-separated-list of builders to pull
new baselines from (can also be provided multiple times)."), |
693 ]) | 685 ]) |
694 | 686 |
695 def _builders_to_pull_from(self): | 687 def _builders_to_pull_from(self): |
696 chosen_names = self._tool.user.prompt_with_list( | 688 return self._tool.user.prompt_with_list( |
697 "Which builder to pull results from:", self._release_builders(), can
_choose_multiple=True) | 689 "Which builder to pull results from:", self._release_builders(), can
_choose_multiple=True) |
698 return [self._builder_with_name(name) for name in chosen_names] | |
699 | |
700 def _builder_with_name(self, name): | |
701 return self._tool.buildbot.builder_with_name(name) | |
702 | 690 |
703 def execute(self, options, args, tool): | 691 def execute(self, options, args, tool): |
704 if not args: | 692 if not args: |
705 _log.error("Must list tests to rebaseline.") | 693 _log.error("Must list tests to rebaseline.") |
706 return | 694 return |
707 | 695 |
708 if options.builders: | 696 if options.builders: |
709 builders_to_check = [] | 697 builders_to_check = [] |
710 for builder_names in options.builders: | 698 for builder_names in options.builders: |
711 builders_to_check += [self._builder_with_name(name) for name in
builder_names.split(",")] | 699 builders_to_check += builder_names.split(",") |
712 else: | 700 else: |
713 builders_to_check = self._builders_to_pull_from() | 701 builders_to_check = self._builders_to_pull_from() |
714 | 702 |
715 test_prefix_list = {} | 703 test_prefix_list = {} |
716 suffixes_to_update = options.suffixes.split(",") | 704 suffixes_to_update = options.suffixes.split(",") |
717 | 705 |
718 for builder in builders_to_check: | 706 for builder in builders_to_check: |
719 for test in args: | 707 for test in args: |
720 if test not in test_prefix_list: | 708 if test not in test_prefix_list: |
721 test_prefix_list[test] = {} | 709 test_prefix_list[test] = {} |
722 build = Build(builder.name()) | 710 build = Build(builder) |
723 test_prefix_list[test][build] = suffixes_to_update | 711 test_prefix_list[test][build] = suffixes_to_update |
724 | 712 |
725 if options.verbose: | 713 if options.verbose: |
726 _log.debug("rebaseline-json: " + str(test_prefix_list)) | 714 _log.debug("rebaseline-json: " + str(test_prefix_list)) |
727 | 715 |
728 self._rebaseline(options, test_prefix_list) | 716 self._rebaseline(options, test_prefix_list) |
729 | 717 |
730 | 718 |
731 class AutoRebaseline(AbstractParallelRebaselineCommand): | 719 class AutoRebaseline(AbstractParallelRebaselineCommand): |
732 name = "auto-rebaseline" | 720 name = "auto-rebaseline" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 issue_already_closed = tool.executive.run_command( | 975 issue_already_closed = tool.executive.run_command( |
988 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], | 976 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], |
989 return_exit_code=True) | 977 return_exit_code=True) |
990 if not issue_already_closed: | 978 if not issue_already_closed: |
991 self._run_git_cl_command(options, ['set_close']) | 979 self._run_git_cl_command(options, ['set_close']) |
992 | 980 |
993 tool.scm().ensure_cleanly_tracking_remote_master() | 981 tool.scm().ensure_cleanly_tracking_remote_master() |
994 if old_branch_name_or_ref: | 982 if old_branch_name_or_ref: |
995 tool.scm().checkout_branch(old_branch_name_or_ref) | 983 tool.scm().checkout_branch(old_branch_name_or_ref) |
996 tool.scm().delete_branch(rebaseline_branch_name) | 984 tool.scm().delete_branch(rebaseline_branch_name) |
OLD | NEW |