| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 from webkitpy.tool.commands.command import Command | 42 from webkitpy.tool.commands.command import Command |
| 43 | 43 |
| 44 | 44 |
| 45 _log = logging.getLogger(__name__) | 45 _log = logging.getLogger(__name__) |
| 46 | 46 |
| 47 | 47 |
| 48 class AbstractRebaseliningCommand(Command): | 48 class AbstractRebaseliningCommand(Command): |
| 49 """Base class for rebaseline-related commands.""" | 49 """Base class for rebaseline-related commands.""" |
| 50 # Not overriding execute() - pylint: disable=abstract-method | 50 # Not overriding execute() - pylint: disable=abstract-method |
| 51 | 51 |
| 52 no_optimize_option = optparse.make_option('--no-optimize', dest='optimize',
action='store_false', default=True, | 52 no_optimize_option = optparse.make_option( |
| 53 help=('Do not optimize (de-duplica
te) the expectations after rebaselining ' | 53 '--no-optimize', dest='optimize', action='store_false', default=True, |
| 54 '(default is to de-dup autom
atically). ' | 54 help=('Do not optimize (de-duplicate) the expectations after rebaselinin
g ' |
| 55 'You can use "webkit-patch o
ptimize-baselines" to optimize separately.')) | 55 '(default is to de-dupe automatically). You can use "webkit-patch
' |
| 56 | 56 'optimize-baselines" to optimize separately.')) |
| 57 platform_options = factory.platform_options(use_globs=True) | 57 platform_options = factory.platform_options(use_globs=True) |
| 58 | 58 results_directory_option = optparse.make_option( |
| 59 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use.") | 59 '--results-directory', help='Local results directory to use.') |
| 60 | 60 suffixes_option = optparse.make_option( |
| 61 suffixes_option = optparse.make_option("--suffixes", default=','.join(BASELI
NE_SUFFIX_LIST), action="store", | 61 '--suffixes', default=','.join(BASELINE_SUFFIX_LIST), action='store', |
| 62 help="Comma-separated-list of file ty
pes to rebaseline.") | 62 help='Comma-separated-list of file types to rebaseline.') |
| 63 builder_option = optparse.make_option( |
| 64 '--builder', help='Builder to pull new baselines from.') |
| 65 test_option = optparse.make_option('--test', help='Test to rebaseline.') |
| 66 build_number_option = optparse.make_option( |
| 67 '--build-number', default=None, type='int', |
| 68 help='Optional build number; if not given, the latest build is used.') |
| 63 | 69 |
| 64 def __init__(self, options=None): | 70 def __init__(self, options=None): |
| 65 super(AbstractRebaseliningCommand, self).__init__(options=options) | 71 super(AbstractRebaseliningCommand, self).__init__(options=options) |
| 66 self._baseline_suffix_list = BASELINE_SUFFIX_LIST | 72 self._baseline_suffix_list = BASELINE_SUFFIX_LIST |
| 67 self.expectation_line_changes = ChangeSet() | 73 self.expectation_line_changes = ChangeSet() |
| 68 self._tool = None | 74 self._tool = None |
| 69 | 75 |
| 70 def _print_expectation_line_changes(self): | 76 def _print_expectation_line_changes(self): |
| 71 print(json.dumps(self.expectation_line_changes.to_dict())) | 77 print(json.dumps(self.expectation_line_changes.to_dict())) |
| 72 | 78 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 125 |
| 120 def update(self, other): | 126 def update(self, other): |
| 121 assert isinstance(other, ChangeSet) | 127 assert isinstance(other, ChangeSet) |
| 122 assert type(other.lines_to_remove) is dict | 128 assert type(other.lines_to_remove) is dict |
| 123 for test in other.lines_to_remove: | 129 for test in other.lines_to_remove: |
| 124 if test not in self.lines_to_remove: | 130 if test not in self.lines_to_remove: |
| 125 self.lines_to_remove[test] = [] | 131 self.lines_to_remove[test] = [] |
| 126 self.lines_to_remove[test].extend(other.lines_to_remove[test]) | 132 self.lines_to_remove[test].extend(other.lines_to_remove[test]) |
| 127 | 133 |
| 128 | 134 |
| 129 class BaseInternalRebaselineCommand(AbstractRebaseliningCommand): | 135 class CopyExistingBaselinesInternal(AbstractRebaseliningCommand): |
| 130 """Base class for rebaseline-related commands that are intended to be used b
y other commands.""" | |
| 131 # Not overriding execute() - pylint: disable=abstract-method | |
| 132 | |
| 133 def __init__(self): | |
| 134 super(BaseInternalRebaselineCommand, self).__init__(options=[ | |
| 135 self.results_directory_option, | |
| 136 self.suffixes_option, | |
| 137 optparse.make_option("--builder", help="Builder to pull new baseline
s from."), | |
| 138 optparse.make_option("--test", help="Test to rebaseline."), | |
| 139 optparse.make_option("--build-number", default=None, type="int", | |
| 140 help="Optional build number; if not given, the
latest build is used."), | |
| 141 ]) | |
| 142 | |
| 143 | |
| 144 class CopyExistingBaselinesInternal(BaseInternalRebaselineCommand): | |
| 145 name = "copy-existing-baselines-internal" | 136 name = "copy-existing-baselines-internal" |
| 146 help_text = ("Copy existing baselines down one level in the baseline order t
o ensure " | 137 help_text = ("Copy existing baselines down one level in the baseline order t
o ensure " |
| 147 "new baselines don't break existing passing platforms.") | 138 "new baselines don't break existing passing platforms.") |
| 148 | 139 |
| 140 def __init__(self): |
| 141 super(CopyExistingBaselinesInternal, self).__init__(options=[ |
| 142 self.results_directory_option, |
| 143 self.suffixes_option, |
| 144 self.builder_option, |
| 145 self.test_option, |
| 146 ]) |
| 147 |
| 149 @memoized | 148 @memoized |
| 150 def _immediate_predecessors_in_fallback(self, path_to_rebaseline): | 149 def _immediate_predecessors_in_fallback(self, path_to_rebaseline): |
| 151 port_names = self._tool.port_factory.all_port_names() | 150 port_names = self._tool.port_factory.all_port_names() |
| 152 immediate_predecessors = [] | 151 immediate_predecessors = [] |
| 153 for port_name in port_names: | 152 for port_name in port_names: |
| 154 port = self._tool.port_factory.get(port_name) | 153 port = self._tool.port_factory.get(port_name) |
| 155 if not port.buildbot_archives_baselines(): | 154 if not port.buildbot_archives_baselines(): |
| 156 continue | 155 continue |
| 157 baseline_search_path = port.baseline_search_path() | 156 baseline_search_path = port.baseline_search_path() |
| 158 try: | 157 try: |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 _log.debug("Copying baseline from %s to %s.", old_baseline, new_base
line) | 205 _log.debug("Copying baseline from %s to %s.", old_baseline, new_base
line) |
| 207 self._tool.filesystem.maybe_make_directory(self._tool.filesystem.dir
name(new_baseline)) | 206 self._tool.filesystem.maybe_make_directory(self._tool.filesystem.dir
name(new_baseline)) |
| 208 self._tool.filesystem.copyfile(old_baseline, new_baseline) | 207 self._tool.filesystem.copyfile(old_baseline, new_baseline) |
| 209 | 208 |
| 210 def execute(self, options, args, tool): | 209 def execute(self, options, args, tool): |
| 211 self._tool = tool | 210 self._tool = tool |
| 212 for suffix in options.suffixes.split(','): | 211 for suffix in options.suffixes.split(','): |
| 213 self._copy_existing_baseline(options.builder, options.test, suffix) | 212 self._copy_existing_baseline(options.builder, options.test, suffix) |
| 214 | 213 |
| 215 | 214 |
| 216 class RebaselineTest(BaseInternalRebaselineCommand): | 215 class RebaselineTest(AbstractRebaseliningCommand): |
| 217 name = "rebaseline-test-internal" | 216 name = "rebaseline-test-internal" |
| 218 help_text = "Rebaseline a single test from a buildbot. Only intended for use
by other webkit-patch commands." | 217 help_text = "Rebaseline a single test from a buildbot. Only intended for use
by other webkit-patch commands." |
| 219 | 218 |
| 219 def __init__(self): |
| 220 super(RebaselineTest, self).__init__(options=[ |
| 221 self.results_directory_option, |
| 222 self.suffixes_option, |
| 223 self.builder_option, |
| 224 self.test_option, |
| 225 self.build_number_option, |
| 226 ]) |
| 227 |
| 220 def _save_baseline(self, data, target_baseline): | 228 def _save_baseline(self, data, target_baseline): |
| 221 if not data: | 229 if not data: |
| 222 _log.debug("No baseline data to save.") | 230 _log.debug("No baseline data to save.") |
| 223 return | 231 return |
| 224 | 232 |
| 225 filesystem = self._tool.filesystem | 233 filesystem = self._tool.filesystem |
| 226 filesystem.maybe_make_directory(filesystem.dirname(target_baseline)) | 234 filesystem.maybe_make_directory(filesystem.dirname(target_baseline)) |
| 227 filesystem.write_binary_file(target_baseline, data) | 235 filesystem.write_binary_file(target_baseline, data) |
| 228 | 236 |
| 229 def _rebaseline_test(self, builder_name, test_name, suffix, results_url): | 237 def _rebaseline_test(self, builder_name, test_name, suffix, results_url): |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 for test in args: | 714 for test in args: |
| 707 if test not in test_prefix_list: | 715 if test not in test_prefix_list: |
| 708 test_prefix_list[test] = {} | 716 test_prefix_list[test] = {} |
| 709 build = Build(builder) | 717 build = Build(builder) |
| 710 test_prefix_list[test][build] = suffixes_to_update | 718 test_prefix_list[test][build] = suffixes_to_update |
| 711 | 719 |
| 712 if options.verbose: | 720 if options.verbose: |
| 713 _log.debug("rebaseline-json: " + str(test_prefix_list)) | 721 _log.debug("rebaseline-json: " + str(test_prefix_list)) |
| 714 | 722 |
| 715 self.rebaseline(options, test_prefix_list) | 723 self.rebaseline(options, test_prefix_list) |
| OLD | NEW |