| 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 |
| 11 from webkitpy.common.net.git_cl import GitCL | 11 from webkitpy.common.net.git_cl import GitCL |
| 12 from webkitpy.layout_tests.models.test_expectations import BASELINE_SUFFIX_LIST | |
| 13 from webkitpy.tool.commands.rebaseline import AbstractParallelRebaselineCommand | 12 from webkitpy.tool.commands.rebaseline import AbstractParallelRebaselineCommand |
| 14 from webkitpy.w3c.wpt_manifest import WPTManifest | 13 from webkitpy.w3c.wpt_manifest import WPTManifest |
| 15 | 14 |
| 16 _log = logging.getLogger(__name__) | 15 _log = logging.getLogger(__name__) |
| 17 | 16 |
| 18 | 17 |
| 19 class RebaselineCL(AbstractParallelRebaselineCommand): | 18 class RebaselineCL(AbstractParallelRebaselineCommand): |
| 20 name = 'rebaseline-cl' | 19 name = 'rebaseline-cl' |
| 21 help_text = 'Fetches new baselines for a CL from test runs on try bots.' | 20 help_text = 'Fetches new baselines for a CL from test runs on try bots.' |
| 22 long_help = ('By default, this command will check the latest try job results
' | 21 long_help = ('By default, this command will check the latest try job results
' |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return 1 | 82 return 1 |
| 84 | 83 |
| 85 _log.debug('Getting results for issue %d.', issue_number) | 84 _log.debug('Getting results for issue %d.', issue_number) |
| 86 builds_to_results = self._fetch_results(builds) | 85 builds_to_results = self._fetch_results(builds) |
| 87 if builds_to_results is None: | 86 if builds_to_results is None: |
| 88 return 1 | 87 return 1 |
| 89 | 88 |
| 90 test_prefix_list = {} | 89 test_prefix_list = {} |
| 91 if args: | 90 if args: |
| 92 for test in args: | 91 for test in args: |
| 93 test_prefix_list[test] = {b: BASELINE_SUFFIX_LIST for b in build
s} | 92 test_prefix_list[test] = builds |
| 94 else: | 93 else: |
| 95 test_prefix_list = self._test_prefix_list( | 94 test_prefix_list = self._test_prefix_list( |
| 96 builds_to_results, | 95 builds_to_results, |
| 97 only_changed_tests=options.only_changed_tests) | 96 only_changed_tests=options.only_changed_tests) |
| 98 | 97 |
| 99 self._log_test_prefix_list(test_prefix_list) | 98 self._log_test_prefix_list(test_prefix_list) |
| 100 | 99 |
| 101 if not options.dry_run: | 100 if not options.dry_run: |
| 102 self.rebaseline(options, test_prefix_list) | 101 self.rebaseline(options, test_prefix_list) |
| 103 return 0 | 102 return 0 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 # the path separator, and they're always relative to repo root. | 184 # the path separator, and they're always relative to repo root. |
| 186 # TODO(qyearsley): Do this without using a hard-coded constant. | 185 # TODO(qyearsley): Do this without using a hard-coded constant. |
| 187 test_base = 'third_party/WebKit/LayoutTests/' | 186 test_base = 'third_party/WebKit/LayoutTests/' |
| 188 tests_in_cl = [f[len(test_base):] for f in files_in_cl if f.startswi
th(test_base)] | 187 tests_in_cl = [f[len(test_base):] for f in files_in_cl if f.startswi
th(test_base)] |
| 189 result = {} | 188 result = {} |
| 190 for build, tests in builds_to_tests.iteritems(): | 189 for build, tests in builds_to_tests.iteritems(): |
| 191 for test in tests: | 190 for test in tests: |
| 192 if only_changed_tests and test not in tests_in_cl: | 191 if only_changed_tests and test not in tests_in_cl: |
| 193 continue | 192 continue |
| 194 if test not in result: | 193 if test not in result: |
| 195 result[test] = {} | 194 result[test] = [] |
| 196 result[test][build] = BASELINE_SUFFIX_LIST | 195 result[test].append(build) |
| 197 return result | 196 return result |
| 198 | 197 |
| 199 def _tests_to_rebaseline(self, build, layout_test_results): | 198 def _tests_to_rebaseline(self, build, layout_test_results): |
| 200 """Fetches a list of tests that should be rebaselined for some build.""" | 199 """Fetches a list of tests that should be rebaselined for some build.""" |
| 201 unexpected_results = layout_test_results.didnt_run_as_expected_results() | 200 unexpected_results = layout_test_results.didnt_run_as_expected_results() |
| 202 tests = sorted(r.test_name() for r in unexpected_results | 201 tests = sorted(r.test_name() for r in unexpected_results |
| 203 if r.is_missing_baseline() or r.has_mismatch_result()) | 202 if r.is_missing_baseline() or r.has_mismatch_result()) |
| 204 | 203 |
| 205 new_failures = self._fetch_tests_with_new_failures(build) | 204 new_failures = self._fetch_tests_with_new_failures(build) |
| 206 if new_failures is None: | 205 if new_failures is None: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 226 def _log_test_prefix_list(test_prefix_list): | 225 def _log_test_prefix_list(test_prefix_list): |
| 227 """Logs the tests to download new baselines for.""" | 226 """Logs the tests to download new baselines for.""" |
| 228 if not test_prefix_list: | 227 if not test_prefix_list: |
| 229 _log.info('No tests to rebaseline; exiting.') | 228 _log.info('No tests to rebaseline; exiting.') |
| 230 return | 229 return |
| 231 _log.debug('Tests to rebaseline:') | 230 _log.debug('Tests to rebaseline:') |
| 232 for test, builds in test_prefix_list.iteritems(): | 231 for test, builds in test_prefix_list.iteritems(): |
| 233 _log.debug(' %s:', test) | 232 _log.debug(' %s:', test) |
| 234 for build in sorted(builds): | 233 for build in sorted(builds): |
| 235 _log.debug(' %s', build) | 234 _log.debug(' %s', build) |
| OLD | NEW |