Chromium Code Reviews| 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 class for updating layout test expectations when updating w3c tests. | 5 """A class for updating layout test expectations when updating w3c tests. |
| 6 | 6 |
| 7 Specifically, this class fetches results from try bots for the current CL, and: | 7 Specifically, this class fetches results from try bots for the current CL, and: |
| 8 1. Downloads new baseline files for any tests that can be rebaselined. | 8 1. Downloads new baseline files for any tests that can be rebaselined. |
| 9 2. Updates the generic TestExpectations file for any other failing tests. | 9 2. Updates the generic TestExpectations file for any other failing tests. |
| 10 | 10 |
| 11 This is used as part of the w3c test auto-import process. | 11 This is used as part of the w3c test auto-import process. |
| 12 """ | 12 """ |
| 13 | 13 |
| 14 import argparse | 14 import argparse |
| 15 import copy | |
| 15 import logging | 16 import logging |
| 16 | 17 |
| 17 from webkitpy.common.net.git_cl import GitCL | 18 from webkitpy.common.net.git_cl import GitCL |
| 18 from webkitpy.common.net.rietveld import Rietveld | 19 from webkitpy.common.net.rietveld import Rietveld |
| 19 from webkitpy.common.webkit_finder import WebKitFinder | 20 from webkitpy.common.webkit_finder import WebKitFinder |
| 20 from webkitpy.w3c.test_parser import TestParser | 21 from webkitpy.w3c.test_parser import TestParser |
| 21 from webkitpy.layout_tests.models.test_expectations import TestExpectationLine | 22 from webkitpy.layout_tests.models.test_expectations import TestExpectationLine |
| 22 | 23 |
| 23 _log = logging.getLogger(__name__) | 24 _log = logging.getLogger(__name__) |
| 24 | 25 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 failure test dictionary. | 295 failure test dictionary. |
| 295 | 296 |
| 296 Args: | 297 Args: |
| 297 tests_results: A dict mapping test name to platform to test results. | 298 tests_results: A dict mapping test name to platform to test results. |
| 298 | 299 |
| 299 Returns: | 300 Returns: |
| 300 An updated tests_results dictionary without the platform-specific | 301 An updated tests_results dictionary without the platform-specific |
| 301 testharness.js tests that required new baselines to be downloaded | 302 testharness.js tests that required new baselines to be downloaded |
| 302 from `webkit-patch rebaseline-from-try-jobs`. | 303 from `webkit-patch rebaseline-from-try-jobs`. |
| 303 """ | 304 """ |
| 304 modified_files = self.host.executive.run_command(['git', 'diff', 'origin /master', '--name-only']).splitlines() | 305 modified_tests = self.get_modified_existing_tests() |
| 305 tests_to_rebaseline, tests_results = self.get_tests_to_rebaseline(modifi ed_files, tests_results) | 306 tests_to_rebaseline, tests_results = self.get_tests_to_rebaseline(modifi ed_tests, tests_results) |
| 306 _log.debug('Tests to rebaseline: %r', tests_to_rebaseline) | 307 _log.debug('Tests to rebaseline: %r', tests_to_rebaseline) |
| 307 if tests_to_rebaseline: | 308 if tests_to_rebaseline: |
| 308 webkit_patch = self.host.filesystem.join( | 309 webkit_patch = self.host.filesystem.join( |
| 309 self.finder.chromium_base(), self.finder.webkit_base(), self.fin der.path_to_script('webkit-patch')) | 310 self.finder.chromium_base(), self.finder.webkit_base(), self.fin der.path_to_script('webkit-patch')) |
| 310 self.host.executive.run_command([ | 311 self.host.executive.run_command([ |
| 311 'python', | 312 'python', |
| 312 webkit_patch, | 313 webkit_patch, |
| 313 'rebaseline-cl', | 314 'rebaseline-cl', |
| 314 '--verbose', | 315 '--verbose', |
| 315 '--no-trigger-jobs', | 316 '--no-trigger-jobs', |
| 316 '--only-changed-tests', | 317 '--only-changed-tests', |
| 317 ] + tests_to_rebaseline) | 318 ] + tests_to_rebaseline) |
| 318 return tests_results | 319 return tests_results |
| 319 | 320 |
| 320 def get_tests_to_rebaseline(self, modified_files, tests_results): | 321 def get_modified_existing_tests(self): |
| 322 """Returns a list of layout test names for layout tests that have been m odified.""" | |
| 323 diff_output = self.host.executive.run_command( | |
| 324 ['git', 'diff', 'origin/master', '--name-only', '-diff-filter=AMR']) # Added, modified, and renamed files. | |
| 325 paths_from_chromium_root = diff_output.splitlines() | |
| 326 modified_tests = [] | |
| 327 for path in paths_from_chromium_root: | |
| 328 absolute_path = self.host.filesystem.join(self.finder.chromium_base( ), path) | |
| 329 if not self.host.filesystem.exists(absolute_path): | |
| 330 _log.warning('File does not exist: %s', absolute_path) | |
| 331 continue | |
| 332 test_path = self.finder.layout_test_name(path) | |
| 333 if test_path: | |
| 334 modified_tests.append(test_path) | |
| 335 return modified_tests | |
| 336 | |
| 337 def get_tests_to_rebaseline(self, modified_tests, test_results): | |
| 321 """Returns a list of tests to download new baselines for. | 338 """Returns a list of tests to download new baselines for. |
| 322 | 339 |
| 323 Creates a list of tests to rebaseline depending on the tests' platform- | 340 Creates a list of tests to rebaseline depending on the tests' platform- |
| 324 specific results. In general, this will be non-ref tests that failed | 341 specific results. In general, this will be non-ref tests that failed |
| 325 due to a baseline mismatch (rather than crash or timeout). | 342 due to a baseline mismatch (rather than crash or timeout). |
| 326 | 343 |
| 327 Args: | 344 Args: |
| 328 modified_files: A list of paths to modified files (which should | 345 modified_tests: A list of paths to modified files (which should |
| 329 be added, removed or modified files in the imported w3c | 346 be added, removed or modified files in the imported w3c |
| 330 directory), relative to the Chromium checkout root. | 347 directory), relative to the LayoutTests directory. |
| 331 tests_results: A dictionary of failing tests results. | 348 test_results: A dictionary of failing tests results. |
| 332 | 349 |
| 333 Returns: | 350 Returns: |
| 334 A pair: A set of tests to be rebaselined, and an updated | 351 A pair: A set of tests to be rebaselined, and an modified updated |
|
jsbell
2016/10/04 23:43:33
Grammar: "an modified updated" doesn't make sense
qyearsley
2016/10/05 17:20:36
Gah, thanks for catching :-) The intended change h
| |
| 335 tests_results dictionary. These tests to be rebaselined includes | 352 test_results dictionary. The tests to be rebaselined should include |
| 336 both testharness.js tests and ref tests that failed some try job. | 353 testharness.js tests that failed due to a baseline mismatch. |
| 337 """ | 354 """ |
| 355 test_results = copy.deepcopy(test_results) | |
| 338 tests_to_rebaseline = set() | 356 tests_to_rebaseline = set() |
| 339 layout_tests_rel_path = self.host.filesystem.relpath( | 357 for test_path in modified_tests: |
| 340 self.finder.layout_tests_dir(), self.finder.chromium_base()) | 358 if not (self.is_js_test(test_path) and test_results.get(test_path)): |
| 341 for file_path in modified_files: | 359 continue |
| 342 test_path = self.host.filesystem.relpath(file_path, layout_tests_rel _path) | 360 for platform in test_results[test_path].keys(): |
| 343 if self.is_js_test(test_path) and tests_results.get(test_path): | 361 if test_results[test_path][platform]['actual'] not in ['CRASH', 'TIMEOUT']: |
| 344 for platform in tests_results[test_path].keys(): | 362 del test_results[test_path][platform] |
| 345 if tests_results[test_path][platform]['actual'] not in ['CRA SH', 'TIMEOUT']: | 363 tests_to_rebaseline.add(test_path) |
| 346 del tests_results[test_path][platform] | 364 return sorted(tests_to_rebaseline), test_results |
| 347 tests_to_rebaseline.add(test_path) | |
| 348 return list(tests_to_rebaseline), tests_results | |
| 349 | 365 |
| 350 def is_js_test(self, test_path): | 366 def is_js_test(self, test_path): |
| 351 """Checks whether a given file is a testharness.js test. | 367 """Checks whether a given file is a testharness.js test. |
| 352 | 368 |
| 353 Args: | 369 Args: |
| 354 test_path: A file path relative to the layout tests directory. | 370 test_path: A file path relative to the layout tests directory. |
| 355 This might correspond to a deleted file or a non-test. | 371 This might correspond to a deleted file or a non-test. |
| 356 """ | 372 """ |
| 357 absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir() , test_path) | 373 absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir() , test_path) |
| 358 test_parser = TestParser(absolute_path, self.host) | 374 test_parser = TestParser(absolute_path, self.host) |
| 359 if not test_parser.test_doc: | 375 if not test_parser.test_doc: |
| 360 return False | 376 return False |
| 361 return test_parser.is_jstest() | 377 return test_parser.is_jstest() |
| OLD | NEW |