| 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 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 self.results_directory_option, | 49 self.results_directory_option, |
| 50 ]) | 50 ]) |
| 51 self.rietveld = Rietveld(Web()) | 51 self.rietveld = Rietveld(Web()) |
| 52 | 52 |
| 53 def execute(self, options, args, tool): | 53 def execute(self, options, args, tool): |
| 54 self._tool = tool | 54 self._tool = tool |
| 55 issue_number = self._get_issue_number(options) | 55 issue_number = self._get_issue_number(options) |
| 56 if not issue_number: | 56 if not issue_number: |
| 57 return | 57 return |
| 58 | 58 |
| 59 builds = self.rietveld.latest_try_jobs(issue_number, self._try_bots()) | 59 builds = self.rietveld.latest_try_job_results(issue_number, self._try_bo
ts()) |
| 60 if options.trigger_jobs: | 60 if options.trigger_jobs: |
| 61 if self.trigger_jobs_for_missing_builds(builds): | 61 if self.trigger_jobs_for_missing_builds(builds): |
| 62 _log.info('Please re-run webkit-patch rebaseline-cl once all pen
ding try jobs have finished.') | 62 _log.info('Please re-run webkit-patch rebaseline-cl once all pen
ding try jobs have finished.') |
| 63 return | 63 return |
| 64 if not builds: | 64 if not builds: |
| 65 # TODO(qyearsley): Also check that there are *finished* builds. | 65 # TODO(qyearsley): Also check that there are *finished* builds. |
| 66 # The current behavior would still proceed if there are queued | 66 # The current behavior would still proceed if there are queued |
| 67 # or started builds. | 67 # or started builds. |
| 68 _log.info('No builds to download baselines from.') | 68 _log.info('No builds to download baselines from.') |
| 69 | 69 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if only_changed_tests and test not in tests_in_cl: | 156 if only_changed_tests and test not in tests_in_cl: |
| 157 continue | 157 continue |
| 158 if test not in result: | 158 if test not in result: |
| 159 result[test] = {} | 159 result[test] = {} |
| 160 result[test][build] = BASELINE_SUFFIX_LIST | 160 result[test][build] = BASELINE_SUFFIX_LIST |
| 161 return result | 161 return result |
| 162 | 162 |
| 163 def _builds_to_tests(self, issue_number): | 163 def _builds_to_tests(self, issue_number): |
| 164 """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.""" |
| 165 _log.debug('Getting results for Rietveld issue %d.', issue_number) | 165 _log.debug('Getting results for Rietveld issue %d.', issue_number) |
| 166 try_jobs = self.rietveld.latest_try_jobs(issue_number, self._try_bots()) | 166 builds = self.rietveld.latest_try_job_results(issue_number, self._try_bo
ts()) |
| 167 if not try_jobs: | 167 if not builds: |
| 168 _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
()) |
| 169 return {build: self._tests_to_rebaseline(build) for build in try_jobs} | 169 return {build: self._tests_to_rebaseline(build) for build in builds} |
| 170 | 170 |
| 171 def _try_bots(self): | 171 def _try_bots(self): |
| 172 """Returns a collection of try bot builders to fetch results for.""" | 172 """Returns a collection of try bot builders to fetch results for.""" |
| 173 return self._tool.builders.all_try_builder_names() | 173 return self._tool.builders.all_try_builder_names() |
| 174 | 174 |
| 175 def _tests_to_rebaseline(self, build): | 175 def _tests_to_rebaseline(self, build): |
| 176 """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.""" |
| 177 buildbot = self._tool.buildbot | 177 buildbot = self._tool.buildbot |
| 178 results_url = buildbot.results_url(build.builder_name, build.build_numbe
r) | 178 results_url = buildbot.results_url(build.builder_name, build.build_numbe
r) |
| 179 layout_test_results = buildbot.fetch_layout_test_results(results_url) | 179 layout_test_results = buildbot.fetch_layout_test_results(results_url) |
| 180 if layout_test_results is None: | 180 if layout_test_results is None: |
| 181 _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) |
| 182 return [] | 182 return [] |
| 183 failure_results = layout_test_results.unexpected_mismatch_results() | 183 failure_results = layout_test_results.unexpected_mismatch_results() |
| 184 missing_results = layout_test_results.missing_results() | 184 missing_results = layout_test_results.missing_results() |
| 185 return sorted(r.test_name() for r in failure_results + missing_results) | 185 return sorted(r.test_name() for r in failure_results + missing_results) |
| 186 | 186 |
| 187 @staticmethod | 187 @staticmethod |
| 188 def _log_test_prefix_list(test_prefix_list): | 188 def _log_test_prefix_list(test_prefix_list): |
| 189 """Logs the tests to download new baselines for.""" | 189 """Logs the tests to download new baselines for.""" |
| 190 if not test_prefix_list: | 190 if not test_prefix_list: |
| 191 _log.info('No tests to rebaseline; exiting.') | 191 _log.info('No tests to rebaseline; exiting.') |
| 192 return | 192 return |
| 193 _log.info('Tests to rebaseline:') | 193 _log.info('Tests to rebaseline:') |
| 194 for test, builds in test_prefix_list.iteritems(): | 194 for test, builds in test_prefix_list.iteritems(): |
| 195 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)) |
| 196 _log.info(' %s: %s', test, builds_str) | 196 _log.info(' %s: %s', test, builds_str) |
| OLD | NEW |