| 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 the current CL.""" | 5 """A command to fetch new baselines from try jobs for the current CL.""" |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 import logging | 8 import logging |
| 9 import optparse | 9 import optparse |
| 10 | 10 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 missing_ports = all_ports - {p for _, p in build_port_pairs} | 243 missing_ports = all_ports - {p for _, p in build_port_pairs} |
| 244 if not missing_ports: | 244 if not missing_ports: |
| 245 continue | 245 continue |
| 246 _log.info('For %s:', test_prefix) | 246 _log.info('For %s:', test_prefix) |
| 247 for port in missing_ports: | 247 for port in missing_ports: |
| 248 build = self._choose_fill_in_build(port, build_port_pairs) | 248 build = self._choose_fill_in_build(port, build_port_pairs) |
| 249 _log.info('Using %s to supply results for %s.', build, port) | 249 _log.info('Using %s to supply results for %s.', build, port) |
| 250 test_baseline_set.add(test_prefix, build, port) | 250 test_baseline_set.add(test_prefix, build, port) |
| 251 return test_baseline_set | 251 return test_baseline_set |
| 252 | 252 |
| 253 def _choose_fill_in_build(self, _, build_port_pairs): | 253 def _choose_fill_in_build(self, target_port, build_port_pairs): |
| 254 """Returns a Build to use to supply results for the given port. | 254 """Returns a Build to use to supply results for the given port. |
| 255 | 255 |
| 256 Ideally, this should return a build for a similar port so that the | 256 Ideally, this should return a build for a similar port so that the |
| 257 results from the selected build may also be correct for the target port. | 257 results from the selected build may also be correct for the target port. |
| 258 """ | 258 """ |
| 259 # TODO(qyearsley): Decide what build to use for a given port | 259 # A full port name should normally always be of the form <os>-<version>; |
| 260 # in a more sophisticated way, such that a build with a | 260 # for example "win-win7", or "linux-trusty". For the test port used in |
| 261 # "similar" port will be used when available. | 261 # unit tests, though, the full port name may be "test-<os>-<version>". |
| 262 return build_port_pairs[0][0] | 262 def os_name(port): |
| 263 if '-' not in port: |
| 264 return port |
| 265 return port[:port.rfind('-')] |
| 266 |
| 267 # If any Build exists with the same OS, use the first one. |
| 268 target_os = os_name(target_port) |
| 269 same_os_builds = sorted(b for b, p in build_port_pairs if os_name(p) ==
target_os) |
| 270 if same_os_builds: |
| 271 return same_os_builds[0] |
| 272 |
| 273 # Otherwise, perhaps any build will do, for example if the results are |
| 274 # the same on all platforms. In this case, just return the first build. |
| 275 return sorted(build_port_pairs)[0][0] |
| OLD | NEW |