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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 # or started builds. | 66 # or started builds. |
67 _log.info('No builds to download baselines from.') | 67 _log.info('No builds to download baselines from.') |
68 | 68 |
69 if args: | 69 if args: |
70 test_prefix_list = {} | 70 test_prefix_list = {} |
71 for test in args: | 71 for test in args: |
72 test_prefix_list[test] = {b: BASELINE_SUFFIX_LIST for b in build
s} | 72 test_prefix_list[test] = {b: BASELINE_SUFFIX_LIST for b in build
s} |
73 else: | 73 else: |
74 test_prefix_list = self._test_prefix_list( | 74 test_prefix_list = self._test_prefix_list( |
75 issue_number, only_changed_tests=options.only_changed_tests) | 75 issue_number, only_changed_tests=options.only_changed_tests) |
| 76 |
| 77 # TODO(qyearsley): Fix places where non-existing tests may be added: |
| 78 # 1. Make sure that the tests obtained when passing --only-changed-test
s include only existing tests. |
| 79 # 2. Make sure that update-w3c-test-expectations doesn't specify non-ex
isting tests (http://crbug.com/649691). |
| 80 test_prefix_list = self._filter_existing(test_prefix_list) |
| 81 |
76 self._log_test_prefix_list(test_prefix_list) | 82 self._log_test_prefix_list(test_prefix_list) |
77 | 83 |
78 if options.dry_run: | 84 if options.dry_run: |
79 return | 85 return |
80 self._rebaseline(options, test_prefix_list) | 86 self._rebaseline(options, test_prefix_list) |
81 | 87 |
| 88 def _filter_existing(self, test_prefix_list): |
| 89 """Filters out entries in |test_prefix_list| for tests that don't exist.
""" |
| 90 new_test_prefix_list = {} |
| 91 port = self._tool.port_factory.get() |
| 92 for test in test_prefix_list: |
| 93 path = port.abspath_for_test(test) |
| 94 if self._tool.filesystem.exists(path): |
| 95 new_test_prefix_list[test] = test_prefix_list[test] |
| 96 else: |
| 97 _log.warning('%s not found, removing from list.', path) |
| 98 return new_test_prefix_list |
| 99 |
82 def _get_issue_number(self, options): | 100 def _get_issue_number(self, options): |
83 """Gets the Rietveld CL number from either |options| or from the current
local branch.""" | 101 """Gets the Rietveld CL number from either |options| or from the current
local branch.""" |
84 if options.issue: | 102 if options.issue: |
85 return options.issue | 103 return options.issue |
86 issue_number = self.git_cl().get_issue_number() | 104 issue_number = self.git_cl().get_issue_number() |
87 _log.debug('Issue number for current branch: %s', issue_number) | 105 _log.debug('Issue number for current branch: %s', issue_number) |
88 if not issue_number.isdigit(): | 106 if not issue_number.isdigit(): |
89 _log.error('No issue number given and no issue for current branch. T
his tool requires a CL\n' | 107 _log.error('No issue number given and no issue for current branch. T
his tool requires a CL\n' |
90 'to operate on; please run `git cl upload` on this branch
first, or use the --issue\n' | 108 'to operate on; please run `git cl upload` on this branch
first, or use the --issue\n' |
91 'option to download baselines for another existing CL.') | 109 'option to download baselines for another existing CL.') |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 @staticmethod | 188 @staticmethod |
171 def _log_test_prefix_list(test_prefix_list): | 189 def _log_test_prefix_list(test_prefix_list): |
172 """Logs the tests to download new baselines for.""" | 190 """Logs the tests to download new baselines for.""" |
173 if not test_prefix_list: | 191 if not test_prefix_list: |
174 _log.info('No tests to rebaseline; exiting.') | 192 _log.info('No tests to rebaseline; exiting.') |
175 return | 193 return |
176 _log.info('Tests to rebaseline:') | 194 _log.info('Tests to rebaseline:') |
177 for test, builds in test_prefix_list.iteritems(): | 195 for test, builds in test_prefix_list.iteritems(): |
178 builds_str = ', '.join(sorted('%s (%s)' % (b.builder_name, b.build_n
umber) for b in builds)) | 196 builds_str = ', '.join(sorted('%s (%s)' % (b.builder_name, b.build_n
umber) for b in builds)) |
179 _log.info(' %s: %s', test, builds_str) | 197 _log.info(' %s: %s', test, builds_str) |
OLD | NEW |