| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """A command to download new baselines for NeedsRebaseline tests. | 5 """A command to download new baselines for NeedsRebaseline tests. |
| 6 | 6 |
| 7 This command checks the list of tests with NeedsRebaseline expectations, | 7 This command checks the list of tests with NeedsRebaseline expectations, |
| 8 and downloads the latest baselines for those tests from the results archived | 8 and downloads the latest baselines for those tests from the results archived |
| 9 by the continuous builders. | 9 by the continuous builders. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import logging | 12 import logging |
| 13 import optparse | 13 import optparse |
| 14 import re | 14 import re |
| 15 import sys | 15 import sys |
| 16 import time | 16 import time |
| 17 import traceback | 17 import traceback |
| 18 import urllib2 | 18 import urllib2 |
| 19 | 19 |
| 20 from webkitpy.common.net.buildbot import Build | 20 from webkitpy.common.net.buildbot import Build, current_build_link |
| 21 from webkitpy.layout_tests.models.test_expectations import TestExpectations, BAS
ELINE_SUFFIX_LIST | 21 from webkitpy.layout_tests.models.test_expectations import TestExpectations, BAS
ELINE_SUFFIX_LIST |
| 22 from webkitpy.tool.commands.rebaseline import AbstractParallelRebaselineCommand | 22 from webkitpy.tool.commands.rebaseline import AbstractParallelRebaselineCommand |
| 23 | 23 |
| 24 | 24 |
| 25 _log = logging.getLogger(__name__) | 25 _log = logging.getLogger(__name__) |
| 26 | 26 |
| 27 | 27 |
| 28 class AutoRebaseline(AbstractParallelRebaselineCommand): | 28 class AutoRebaseline(AbstractParallelRebaselineCommand): |
| 29 name = "auto-rebaseline" | 29 name = "auto-rebaseline" |
| 30 help_text = "Rebaselines any NeedsRebaseline lines in TestExpectations that
have cycled through all the bots." | 30 help_text = "Rebaselines any NeedsRebaseline lines in TestExpectations that
have cycled through all the bots." |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 bugs.update(re.findall(r"crbug\.com\/(\d+)", line)) | 129 bugs.update(re.findall(r"crbug\.com\/(\d+)", line)) |
| 130 tests.add(test) | 130 tests.add(test) |
| 131 | 131 |
| 132 if len(tests) >= self.MAX_LINES_TO_REBASELINE: | 132 if len(tests) >= self.MAX_LINES_TO_REBASELINE: |
| 133 _log.info("Too many tests to rebaseline in one patch. Doing the
first %d.", self.MAX_LINES_TO_REBASELINE) | 133 _log.info("Too many tests to rebaseline in one patch. Doing the
first %d.", self.MAX_LINES_TO_REBASELINE) |
| 134 break | 134 break |
| 135 | 135 |
| 136 return tests, revision, commit, author, bugs, has_any_needs_rebaseline_l
ines | 136 return tests, revision, commit, author, bugs, has_any_needs_rebaseline_l
ines |
| 137 | 137 |
| 138 def commit_message(self, author, revision, commit, bugs): |
| 139 message = 'Auto-rebaseline for r%s\n\n' % revision |
| 140 build_link = current_build_link(self._tool) |
| 141 if build_link: |
| 142 message += 'Build: %s\n\n' % build_link |
| 143 message += '%s\n\n' % self.link_to_patch(commit) |
| 144 if bugs: |
| 145 message += 'BUG=%s\n' % ','.join(bugs) |
| 146 message += 'TBR=%s\n' % author |
| 147 return message |
| 148 |
| 138 @staticmethod | 149 @staticmethod |
| 139 def link_to_patch(commit): | 150 def link_to_patch(commit): |
| 140 return "https://chromium.googlesource.com/chromium/src/+/" + commit | 151 return 'https://chromium.googlesource.com/chromium/src/+/' + commit |
| 141 | |
| 142 def commit_message(self, author, revision, commit, bugs): | |
| 143 bug_string = "" | |
| 144 if bugs: | |
| 145 bug_string = "BUG=%s\n" % ",".join(bugs) | |
| 146 | |
| 147 return """Auto-rebaseline for r%s | |
| 148 | |
| 149 %s | |
| 150 | |
| 151 %sTBR=%s | |
| 152 """ % (revision, self.link_to_patch(commit), bug_string, author) | |
| 153 | 152 |
| 154 def get_test_prefix_list(self, tests): | 153 def get_test_prefix_list(self, tests): |
| 155 test_prefix_list = {} | 154 test_prefix_list = {} |
| 156 lines_to_remove = {} | 155 lines_to_remove = {} |
| 157 | 156 |
| 158 for builder_name in self._release_builders(): | 157 for builder_name in self._release_builders(): |
| 159 port_name = self._tool.builders.port_name_for_builder_name(builder_n
ame) | 158 port_name = self._tool.builders.port_name_for_builder_name(builder_n
ame) |
| 160 port = self._tool.port_factory.get(port_name) | 159 port = self._tool.port_factory.get(port_name) |
| 161 expectations = TestExpectations(port, include_overrides=True) | 160 expectations = TestExpectations(port, include_overrides=True) |
| 162 for test in expectations.get_needs_rebaseline_failures(): | 161 for test in expectations.get_needs_rebaseline_failures(): |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 issue_already_closed = tool.executive.run_command( | 288 issue_already_closed = tool.executive.run_command( |
| 290 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], | 289 ['git', 'config', 'branch.%s.rietveldissue' % rebaseline
_branch_name], |
| 291 return_exit_code=True) | 290 return_exit_code=True) |
| 292 if not issue_already_closed: | 291 if not issue_already_closed: |
| 293 self._run_git_cl_command(options, ['set_close']) | 292 self._run_git_cl_command(options, ['set_close']) |
| 294 | 293 |
| 295 tool.scm().ensure_cleanly_tracking_remote_master() | 294 tool.scm().ensure_cleanly_tracking_remote_master() |
| 296 if old_branch_name_or_ref: | 295 if old_branch_name_or_ref: |
| 297 tool.scm().checkout_branch(old_branch_name_or_ref) | 296 tool.scm().checkout_branch(old_branch_name_or_ref) |
| 298 tool.scm().delete_branch(rebaseline_branch_name) | 297 tool.scm().delete_branch(rebaseline_branch_name) |
| OLD | NEW |