| 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 fetch new baselines from try jobs for a Rietveld issue. | 5 """A command to fetch new baselines from try jobs for a Rietveld issue. |
| 6 | 6 |
| 7 This command interacts with the Rietveld API to get information about try jobs | 7 This command interacts with the Rietveld API to get information about try jobs |
| 8 with layout test results. | 8 with layout test results. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import logging | 11 import logging |
| 12 import optparse | 12 import optparse |
| 13 | 13 |
| 14 from webkitpy.common.net.buildbot import Build | |
| 15 from webkitpy.common.net.rietveld import Rietveld | 14 from webkitpy.common.net.rietveld import Rietveld |
| 16 from webkitpy.common.net.web import Web | 15 from webkitpy.common.net.web import Web |
| 17 from webkitpy.common.net.git_cl import GitCL | 16 from webkitpy.common.net.git_cl import GitCL |
| 18 from webkitpy.common.webkit_finder import WebKitFinder | 17 from webkitpy.common.webkit_finder import WebKitFinder |
| 19 from webkitpy.layout_tests.models.test_expectations import BASELINE_SUFFIX_LIST | 18 from webkitpy.layout_tests.models.test_expectations import BASELINE_SUFFIX_LIST |
| 20 from webkitpy.tool.commands.rebaseline import AbstractParallelRebaselineCommand | 19 from webkitpy.tool.commands.rebaseline import AbstractParallelRebaselineCommand |
| 21 | 20 |
| 22 _log = logging.getLogger(__name__) | 21 _log = logging.getLogger(__name__) |
| 23 | 22 |
| 24 | 23 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 result[test] = {} | 159 result[test] = {} |
| 161 result[test][build] = BASELINE_SUFFIX_LIST | 160 result[test][build] = BASELINE_SUFFIX_LIST |
| 162 return result | 161 return result |
| 163 | 162 |
| 164 def _builds_to_tests(self, issue_number): | 163 def _builds_to_tests(self, issue_number): |
| 165 """Fetches a list of try bots, and for each, fetches tests with new base
lines.""" | 164 """Fetches a list of try bots, and for each, fetches tests with new base
lines.""" |
| 166 _log.debug('Getting results for Rietveld issue %d.', issue_number) | 165 _log.debug('Getting results for Rietveld issue %d.', issue_number) |
| 167 try_jobs = self.rietveld.latest_try_jobs(issue_number, self._try_bots()) | 166 try_jobs = self.rietveld.latest_try_jobs(issue_number, self._try_bots()) |
| 168 if not try_jobs: | 167 if not try_jobs: |
| 169 _log.debug('No try job results for builders in: %r.', self._try_bots
()) | 168 _log.debug('No try job results for builders in: %r.', self._try_bots
()) |
| 170 builds_to_tests = {} | 169 return {build: self._tests_to_rebaseline(build) for build in try_jobs} |
| 171 for job in try_jobs: | |
| 172 test_results = self._unexpected_mismatch_results(job) | |
| 173 build = Build(job.builder_name, job.build_number) | |
| 174 builds_to_tests[build] = sorted(r.test_name() for r in test_results) | |
| 175 return builds_to_tests | |
| 176 | 170 |
| 177 def _try_bots(self): | 171 def _try_bots(self): |
| 178 """Returns a collection of try bot builders to fetch results for.""" | 172 """Returns a collection of try bot builders to fetch results for.""" |
| 179 return self._tool.builders.all_try_builder_names() | 173 return self._tool.builders.all_try_builder_names() |
| 180 | 174 |
| 181 def _unexpected_mismatch_results(self, try_job): | 175 def _tests_to_rebaseline(self, build): |
| 182 """Fetches a list of LayoutTestResult objects for unexpected results wit
h new baselines.""" | 176 """Fetches a list of LayoutTestResult objects for unexpected results wit
h new baselines.""" |
| 183 buildbot = self._tool.buildbot | 177 buildbot = self._tool.buildbot |
| 184 results_url = buildbot.results_url(try_job.builder_name, try_job.build_n
umber) | 178 results_url = buildbot.results_url(build.builder_name, build.build_numbe
r) |
| 185 layout_test_results = buildbot.fetch_layout_test_results(results_url) | 179 layout_test_results = buildbot.fetch_layout_test_results(results_url) |
| 186 if layout_test_results is None: | 180 if layout_test_results is None: |
| 187 _log.warning('Failed to request layout test results from "%s".', res
ults_url) | 181 _log.warning('Failed to request layout test results from "%s".', res
ults_url) |
| 188 return [] | 182 return [] |
| 189 return layout_test_results.unexpected_mismatch_results() | 183 failure_results = layout_test_results.unexpected_mismatch_results() |
| 184 missing_results = layout_test_results.missing_results() |
| 185 return sorted(r.test_name() for r in failure_results + missing_results) |
| 190 | 186 |
| 191 @staticmethod | 187 @staticmethod |
| 192 def _log_test_prefix_list(test_prefix_list): | 188 def _log_test_prefix_list(test_prefix_list): |
| 193 """Logs the tests to download new baselines for.""" | 189 """Logs the tests to download new baselines for.""" |
| 194 if not test_prefix_list: | 190 if not test_prefix_list: |
| 195 _log.info('No tests to rebaseline; exiting.') | 191 _log.info('No tests to rebaseline; exiting.') |
| 196 return | 192 return |
| 197 _log.info('Tests to rebaseline:') | 193 _log.info('Tests to rebaseline:') |
| 198 for test, builds in test_prefix_list.iteritems(): | 194 for test, builds in test_prefix_list.iteritems(): |
| 199 builds_str = ', '.join(sorted('%s (%s)' % (b.builder_name, b.build_n
umber) for b in builds)) | 195 builds_str = ', '.join(sorted('%s (%s)' % (b.builder_name, b.build_n
umber) for b in builds)) |
| 200 _log.info(' %s: %s', test, builds_str) | 196 _log.info(' %s: %s', test, builds_str) |
| OLD | NEW |