| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 for test_name in tests: | 271 for test_name in tests: |
| 272 files_to_delete, files_to_add = self._optimize_baseline(optimizer, t
est_name) | 272 files_to_delete, files_to_add = self._optimize_baseline(optimizer, t
est_name) |
| 273 for path in files_to_delete: | 273 for path in files_to_delete: |
| 274 self._delete_from_scm_later(path) | 274 self._delete_from_scm_later(path) |
| 275 for path in files_to_add: | 275 for path in files_to_add: |
| 276 self._add_to_scm_later(path) | 276 self._add_to_scm_later(path) |
| 277 | 277 |
| 278 print json.dumps(self._scm_changes) | 278 print json.dumps(self._scm_changes) |
| 279 | 279 |
| 280 | 280 |
| 281 class AnalyzeBaselines(AbstractRebaseliningCommand): | |
| 282 name = "analyze-baselines" | |
| 283 help_text = "Analyzes the baselines for the given tests and prints results t
hat are identical." | |
| 284 show_in_main_help = True | |
| 285 argument_names = "TEST_NAMES" | |
| 286 | |
| 287 def __init__(self): | |
| 288 super(AnalyzeBaselines, self).__init__(options=[ | |
| 289 self.suffixes_option, | |
| 290 optparse.make_option('--missing', action='store_true', default=False
, help='Show missing baselines as well.'), | |
| 291 ] + self.platform_options) | |
| 292 self._optimizer_class = BaselineOptimizer # overridable for testing | |
| 293 self._baseline_optimizer = None | |
| 294 self._port = None | |
| 295 | |
| 296 def _write(self, msg): | |
| 297 print msg | |
| 298 | |
| 299 def _analyze_baseline(self, options, test_name): | |
| 300 for suffix in self._baseline_suffix_list: | |
| 301 baseline_name = _baseline_name(self._tool.filesystem, test_name, suf
fix) | |
| 302 results_by_directory = self._baseline_optimizer.read_results_by_dire
ctory(baseline_name) | |
| 303 if results_by_directory: | |
| 304 self._write("%s:" % baseline_name) | |
| 305 self._baseline_optimizer.write_by_directory(results_by_directory
, self._write, " ") | |
| 306 elif options.missing: | |
| 307 self._write("%s: (no baselines found)" % baseline_name) | |
| 308 | |
| 309 def execute(self, options, args, tool): | |
| 310 self._baseline_suffix_list = options.suffixes.split(',') | |
| 311 port_names = tool.port_factory.all_port_names(options.platform) | |
| 312 if not port_names: | |
| 313 print "No port names match '%s'" % options.platform | |
| 314 return | |
| 315 self._port = tool.port_factory.get(port_names[0]) | |
| 316 self._baseline_optimizer = self._optimizer_class(tool, self._port, port_
names, skip_scm_commands=False) | |
| 317 for test_name in self._port.tests(args): | |
| 318 self._analyze_baseline(options, test_name) | |
| 319 | |
| 320 | |
| 321 class AbstractParallelRebaselineCommand(AbstractRebaseliningCommand): | 281 class AbstractParallelRebaselineCommand(AbstractRebaseliningCommand): |
| 322 """Base class for rebaseline commands that do some tasks in parallel.""" | 282 """Base class for rebaseline commands that do some tasks in parallel.""" |
| 323 # Not overriding execute() - pylint: disable=abstract-method | 283 # Not overriding execute() - pylint: disable=abstract-method |
| 324 | 284 |
| 325 def __init__(self, options=None): | 285 def __init__(self, options=None): |
| 326 super(AbstractParallelRebaselineCommand, self).__init__(options=options) | 286 super(AbstractParallelRebaselineCommand, self).__init__(options=options) |
| 327 self._builder_data = {} | 287 self._builder_data = {} |
| 328 | 288 |
| 329 def builder_data(self): | 289 def builder_data(self): |
| 330 if not self._builder_data: | 290 if not self._builder_data: |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 issue_already_closed = tool.executive.run_command( | 898 issue_already_closed = tool.executive.run_command( |
| 939 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], | 899 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], |
| 940 return_exit_code=True) | 900 return_exit_code=True) |
| 941 if not issue_already_closed: | 901 if not issue_already_closed: |
| 942 self._run_git_cl_command(options, ['set_close']) | 902 self._run_git_cl_command(options, ['set_close']) |
| 943 | 903 |
| 944 tool.scm().ensure_cleanly_tracking_remote_master() | 904 tool.scm().ensure_cleanly_tracking_remote_master() |
| 945 if old_branch_name_or_ref: | 905 if old_branch_name_or_ref: |
| 946 tool.scm().checkout_branch(old_branch_name_or_ref) | 906 tool.scm().checkout_branch(old_branch_name_or_ref) |
| 947 tool.scm().delete_branch(rebaseline_branch_name) | 907 tool.scm().delete_branch(rebaseline_branch_name) |
| OLD | NEW |