| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use.") | 58 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use.") |
| 59 | 59 |
| 60 suffixes_option = optparse.make_option("--suffixes", default=','.join(BASELI
NE_SUFFIX_LIST), action="store", | 60 suffixes_option = optparse.make_option("--suffixes", default=','.join(BASELI
NE_SUFFIX_LIST), action="store", |
| 61 help="Comma-separated-list of file ty
pes to rebaseline.") | 61 help="Comma-separated-list of file ty
pes to rebaseline.") |
| 62 | 62 |
| 63 def __init__(self, options=None): | 63 def __init__(self, options=None): |
| 64 super(AbstractRebaseliningCommand, self).__init__(options=options) | 64 super(AbstractRebaseliningCommand, self).__init__(options=options) |
| 65 self._baseline_suffix_list = BASELINE_SUFFIX_LIST | 65 self._baseline_suffix_list = BASELINE_SUFFIX_LIST |
| 66 self._scm_changes = {'add': [], 'delete': [], 'remove-lines': []} | 66 self._scm_changes = {'add': [], 'delete': [], 'remove-lines': []} |
| 67 self._tool = None |
| 67 | 68 |
| 68 def _add_to_scm_later(self, path): | 69 def _add_to_scm_later(self, path): |
| 69 self._scm_changes['add'].append(path) | 70 self._scm_changes['add'].append(path) |
| 70 | 71 |
| 71 def _delete_from_scm_later(self, path): | 72 def _delete_from_scm_later(self, path): |
| 72 self._scm_changes['delete'].append(path) | 73 self._scm_changes['delete'].append(path) |
| 73 | 74 |
| 74 def _print_scm_changes(self): | 75 def _print_scm_changes(self): |
| 75 print(json.dumps(self._scm_changes)) | 76 print(json.dumps(self._scm_changes)) |
| 76 | 77 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 old_baseline = old_baselines[i] | 166 old_baseline = old_baselines[i] |
| 166 new_baseline = new_baselines[i] | 167 new_baseline = new_baselines[i] |
| 167 | 168 |
| 168 _log.debug("Copying baseline from %s to %s.", old_baseline, new_base
line) | 169 _log.debug("Copying baseline from %s to %s.", old_baseline, new_base
line) |
| 169 self._tool.filesystem.maybe_make_directory(self._tool.filesystem.dir
name(new_baseline)) | 170 self._tool.filesystem.maybe_make_directory(self._tool.filesystem.dir
name(new_baseline)) |
| 170 self._tool.filesystem.copyfile(old_baseline, new_baseline) | 171 self._tool.filesystem.copyfile(old_baseline, new_baseline) |
| 171 if not self._tool.scm().exists(new_baseline): | 172 if not self._tool.scm().exists(new_baseline): |
| 172 self._add_to_scm_later(new_baseline) | 173 self._add_to_scm_later(new_baseline) |
| 173 | 174 |
| 174 def execute(self, options, args, tool): | 175 def execute(self, options, args, tool): |
| 176 self._tool = tool |
| 175 for suffix in options.suffixes.split(','): | 177 for suffix in options.suffixes.split(','): |
| 176 self._copy_existing_baseline(options.builder, options.test, suffix) | 178 self._copy_existing_baseline(options.builder, options.test, suffix) |
| 177 self._print_scm_changes() | 179 self._print_scm_changes() |
| 178 | 180 |
| 179 | 181 |
| 180 class RebaselineTest(BaseInternalRebaselineCommand): | 182 class RebaselineTest(BaseInternalRebaselineCommand): |
| 181 name = "rebaseline-test-internal" | 183 name = "rebaseline-test-internal" |
| 182 help_text = "Rebaseline a single test from a buildbot. Only intended for use
by other webkit-patch commands." | 184 help_text = "Rebaseline a single test from a buildbot. Only intended for use
by other webkit-patch commands." |
| 183 | 185 |
| 184 def _save_baseline(self, data, target_baseline): | 186 def _save_baseline(self, data, target_baseline): |
| (...skipping 30 matching lines...) Expand all Loading... |
| 215 if options.results_directory: | 217 if options.results_directory: |
| 216 results_url = 'file://' + options.results_directory | 218 results_url = 'file://' + options.results_directory |
| 217 else: | 219 else: |
| 218 results_url = self._tool.buildbot.results_url(options.builder, build
_number=options.build_number) | 220 results_url = self._tool.buildbot.results_url(options.builder, build
_number=options.build_number) |
| 219 | 221 |
| 220 for suffix in self._baseline_suffix_list: | 222 for suffix in self._baseline_suffix_list: |
| 221 self._rebaseline_test(options.builder, options.test, suffix, results
_url) | 223 self._rebaseline_test(options.builder, options.test, suffix, results
_url) |
| 222 self._scm_changes['remove-lines'].append({'builder': options.builder, 't
est': options.test}) | 224 self._scm_changes['remove-lines'].append({'builder': options.builder, 't
est': options.test}) |
| 223 | 225 |
| 224 def execute(self, options, args, tool): | 226 def execute(self, options, args, tool): |
| 227 self._tool = tool |
| 225 self._rebaseline_test_and_update_expectations(options) | 228 self._rebaseline_test_and_update_expectations(options) |
| 226 self._print_scm_changes() | 229 self._print_scm_changes() |
| 227 | 230 |
| 228 | 231 |
| 229 class AbstractParallelRebaselineCommand(AbstractRebaseliningCommand): | 232 class AbstractParallelRebaselineCommand(AbstractRebaseliningCommand): |
| 230 """Base class for rebaseline commands that do some tasks in parallel.""" | 233 """Base class for rebaseline commands that do some tasks in parallel.""" |
| 231 # Not overriding execute() - pylint: disable=abstract-method | 234 # Not overriding execute() - pylint: disable=abstract-method |
| 232 | 235 |
| 233 def __init__(self, options=None): | 236 def __init__(self, options=None): |
| 234 super(AbstractParallelRebaselineCommand, self).__init__(options=options) | 237 super(AbstractParallelRebaselineCommand, self).__init__(options=options) |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 name = "rebaseline-json" | 530 name = "rebaseline-json" |
| 528 help_text = "Rebaseline based off JSON passed to stdin. Intended to only be
called from other scripts." | 531 help_text = "Rebaseline based off JSON passed to stdin. Intended to only be
called from other scripts." |
| 529 | 532 |
| 530 def __init__(self,): | 533 def __init__(self,): |
| 531 super(RebaselineJson, self).__init__(options=[ | 534 super(RebaselineJson, self).__init__(options=[ |
| 532 self.no_optimize_option, | 535 self.no_optimize_option, |
| 533 self.results_directory_option, | 536 self.results_directory_option, |
| 534 ]) | 537 ]) |
| 535 | 538 |
| 536 def execute(self, options, args, tool): | 539 def execute(self, options, args, tool): |
| 540 self._tool = tool |
| 537 self._rebaseline(options, json.loads(sys.stdin.read())) | 541 self._rebaseline(options, json.loads(sys.stdin.read())) |
| 538 | 542 |
| 539 | 543 |
| 540 class RebaselineExpectations(AbstractParallelRebaselineCommand): | 544 class RebaselineExpectations(AbstractParallelRebaselineCommand): |
| 541 name = "rebaseline-expectations" | 545 name = "rebaseline-expectations" |
| 542 help_text = "Rebaselines the tests indicated in TestExpectations." | 546 help_text = "Rebaselines the tests indicated in TestExpectations." |
| 543 show_in_main_help = True | 547 show_in_main_help = True |
| 544 | 548 |
| 545 def __init__(self): | 549 def __init__(self): |
| 546 super(RebaselineExpectations, self).__init__(options=[ | 550 super(RebaselineExpectations, self).__init__(options=[ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 567 if tests: | 571 if tests: |
| 568 _log.info("Retrieving results for %s from %s.", port_name, builder_n
ame) | 572 _log.info("Retrieving results for %s from %s.", port_name, builder_n
ame) |
| 569 | 573 |
| 570 for test_name, suffixes in tests: | 574 for test_name, suffixes in tests: |
| 571 _log.info(" %s (%s)", test_name, ','.join(suffixes)) | 575 _log.info(" %s (%s)", test_name, ','.join(suffixes)) |
| 572 if test_name not in self._test_prefix_list: | 576 if test_name not in self._test_prefix_list: |
| 573 self._test_prefix_list[test_name] = {} | 577 self._test_prefix_list[test_name] = {} |
| 574 self._test_prefix_list[test_name][Build(builder_name)] = suffixes | 578 self._test_prefix_list[test_name][Build(builder_name)] = suffixes |
| 575 | 579 |
| 576 def execute(self, options, args, tool): | 580 def execute(self, options, args, tool): |
| 581 self._tool = tool |
| 577 options.results_directory = None | 582 options.results_directory = None |
| 578 self._test_prefix_list = {} | 583 self._test_prefix_list = {} |
| 579 port_names = tool.port_factory.all_port_names(options.platform) | 584 port_names = tool.port_factory.all_port_names(options.platform) |
| 580 for port_name in port_names: | 585 for port_name in port_names: |
| 581 self._add_tests_to_rebaseline(port_name) | 586 self._add_tests_to_rebaseline(port_name) |
| 582 if not self._test_prefix_list: | 587 if not self._test_prefix_list: |
| 583 _log.warning("Did not find any tests marked Rebaseline.") | 588 _log.warning("Did not find any tests marked Rebaseline.") |
| 584 return | 589 return |
| 585 | 590 |
| 586 self._rebaseline(options, self._test_prefix_list) | 591 self._rebaseline(options, self._test_prefix_list) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 601 optparse.make_option("--builders", default=None, action="append", | 606 optparse.make_option("--builders", default=None, action="append", |
| 602 help=("Comma-separated-list of builders to pull
new baselines from " | 607 help=("Comma-separated-list of builders to pull
new baselines from " |
| 603 "(can also be provided multiple times).")
), | 608 "(can also be provided multiple times).")
), |
| 604 ]) | 609 ]) |
| 605 | 610 |
| 606 def _builders_to_pull_from(self): | 611 def _builders_to_pull_from(self): |
| 607 return self._tool.user.prompt_with_list( | 612 return self._tool.user.prompt_with_list( |
| 608 "Which builder to pull results from:", self._release_builders(), can
_choose_multiple=True) | 613 "Which builder to pull results from:", self._release_builders(), can
_choose_multiple=True) |
| 609 | 614 |
| 610 def execute(self, options, args, tool): | 615 def execute(self, options, args, tool): |
| 616 self._tool = tool |
| 611 if not args: | 617 if not args: |
| 612 _log.error("Must list tests to rebaseline.") | 618 _log.error("Must list tests to rebaseline.") |
| 613 return | 619 return |
| 614 | 620 |
| 615 if options.builders: | 621 if options.builders: |
| 616 builders_to_check = [] | 622 builders_to_check = [] |
| 617 for builder_names in options.builders: | 623 for builder_names in options.builders: |
| 618 builders_to_check += builder_names.split(",") | 624 builders_to_check += builder_names.split(",") |
| 619 else: | 625 else: |
| 620 builders_to_check = self._builders_to_pull_from() | 626 builders_to_check = self._builders_to_pull_from() |
| 621 | 627 |
| 622 test_prefix_list = {} | 628 test_prefix_list = {} |
| 623 suffixes_to_update = options.suffixes.split(",") | 629 suffixes_to_update = options.suffixes.split(",") |
| 624 | 630 |
| 625 for builder in builders_to_check: | 631 for builder in builders_to_check: |
| 626 for test in args: | 632 for test in args: |
| 627 if test not in test_prefix_list: | 633 if test not in test_prefix_list: |
| 628 test_prefix_list[test] = {} | 634 test_prefix_list[test] = {} |
| 629 build = Build(builder) | 635 build = Build(builder) |
| 630 test_prefix_list[test][build] = suffixes_to_update | 636 test_prefix_list[test][build] = suffixes_to_update |
| 631 | 637 |
| 632 if options.verbose: | 638 if options.verbose: |
| 633 _log.debug("rebaseline-json: " + str(test_prefix_list)) | 639 _log.debug("rebaseline-json: " + str(test_prefix_list)) |
| 634 | 640 |
| 635 self._rebaseline(options, test_prefix_list) | 641 self._rebaseline(options, test_prefix_list) |
| OLD | NEW |