| 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 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 failure test dictionary. | 286 failure test dictionary. |
| 287 | 287 |
| 288 Args: | 288 Args: |
| 289 tests_results: A dict mapping test name to platform to test results. | 289 tests_results: A dict mapping test name to platform to test results. |
| 290 | 290 |
| 291 Returns: | 291 Returns: |
| 292 An updated tests_results dictionary without the platform-specific | 292 An updated tests_results dictionary without the platform-specific |
| 293 testharness.js tests that required new baselines to be downloaded | 293 testharness.js tests that required new baselines to be downloaded |
| 294 from `webkit-patch rebaseline-from-try-jobs`. | 294 from `webkit-patch rebaseline-from-try-jobs`. |
| 295 """ | 295 """ |
| 296 tests = self.host.executive.run_command(['git', 'diff', 'master', '--nam
e-only']).splitlines() | 296 modified_files = self.host.executive.run_command(['git', 'diff', 'master
', '--name-only']).splitlines() |
| 297 tests_to_rebaseline, tests_results = self.get_tests_to_rebaseline(tests,
tests_results) | 297 tests_to_rebaseline, tests_results = self.get_tests_to_rebaseline(modifi
ed_files, tests_results) |
| 298 if tests_to_rebaseline: | 298 if tests_to_rebaseline: |
| 299 webkit_patch = self.host.filesystem.join( | 299 webkit_patch = self.host.filesystem.join( |
| 300 self.finder.chromium_base(), self.finder.webkit_base(), self.fin
der.path_to_script('webkit-patch')) | 300 self.finder.chromium_base(), self.finder.webkit_base(), self.fin
der.path_to_script('webkit-patch')) |
| 301 self.host.executive.run_command([ | 301 self.host.executive.run_command([ |
| 302 'python', | 302 'python', |
| 303 webkit_patch, | 303 webkit_patch, |
| 304 'rebaseline-cl', | 304 'rebaseline-cl', |
| 305 '--verbose', | 305 '--verbose', |
| 306 '--no-trigger-jobs', | 306 '--no-trigger-jobs', |
| 307 ] + tests_to_rebaseline) | 307 ] + tests_to_rebaseline) |
| 308 return tests_results | 308 return tests_results |
| 309 | 309 |
| 310 def get_tests_to_rebaseline(self, tests, tests_results): | 310 def get_tests_to_rebaseline(self, modified_files, tests_results): |
| 311 """Returns a list of tests to download new baselines for. | 311 """Returns a list of tests to download new baselines for. |
| 312 | 312 |
| 313 Creates a list of tests to rebaseline depending on the tests' platform- | 313 Creates a list of tests to rebaseline depending on the tests' platform- |
| 314 specific results. In general, this will be non-ref tests that failed | 314 specific results. In general, this will be non-ref tests that failed |
| 315 due to a baseline mismatch (rather than crash or timeout). | 315 due to a baseline mismatch (rather than crash or timeout). |
| 316 | 316 |
| 317 Args: | 317 Args: |
| 318 tests: A list of new imported tests. | 318 modified_files: A list of paths to modified files (which should |
| 319 be added, removed or modified files in the imported w3c |
| 320 directory), relative to the Chromium checkout root. |
| 319 tests_results: A dictionary of failing tests results. | 321 tests_results: A dictionary of failing tests results. |
| 320 | 322 |
| 321 Returns: | 323 Returns: |
| 322 A pair: A set of tests to be rebaselined, and an updated | 324 A pair: A set of tests to be rebaselined, and an updated |
| 323 tests_results dictionary. These tests to be rebaselined includes | 325 tests_results dictionary. These tests to be rebaselined includes |
| 324 both testharness.js tests and ref tests that failed some try job. | 326 both testharness.js tests and ref tests that failed some try job. |
| 325 """ | 327 """ |
| 326 tests_to_rebaseline = set() | 328 tests_to_rebaseline = set() |
| 327 layout_tests_rel_path = self.host.filesystem.relpath( | 329 layout_tests_rel_path = self.host.filesystem.relpath( |
| 328 self.finder.layout_tests_dir(), self.finder.chromium_base()) | 330 self.finder.layout_tests_dir(), self.finder.chromium_base()) |
| 329 for test in tests: | 331 for file_path in modified_files: |
| 330 test_path = self.host.filesystem.relpath(test, layout_tests_rel_path
) | 332 test_path = self.host.filesystem.relpath(file_path, layout_tests_rel
_path) |
| 331 if self.is_js_test(test) and tests_results.get(test_path): | 333 if self.is_js_test(test_path) and tests_results.get(test_path): |
| 332 for platform in tests_results[test_path].keys(): | 334 for platform in tests_results[test_path].keys(): |
| 333 if tests_results[test_path][platform]['actual'] not in ['CRA
SH', 'TIMEOUT']: | 335 if tests_results[test_path][platform]['actual'] not in ['CRA
SH', 'TIMEOUT']: |
| 334 del tests_results[test_path][platform] | 336 del tests_results[test_path][platform] |
| 335 tests_to_rebaseline.add(test_path) | 337 tests_to_rebaseline.add(test_path) |
| 336 return list(tests_to_rebaseline), tests_results | 338 return list(tests_to_rebaseline), tests_results |
| 337 | 339 |
| 338 def is_js_test(self, test_path): | 340 def is_js_test(self, test_path): |
| 339 absolute_path = self.host.filesystem.join(self.finder.chromium_base(), t
est_path) | 341 """Checks whether a given file is a testharness.js test. |
| 342 |
| 343 Args: |
| 344 test_path: A file path relative to the layout tests directory. |
| 345 This might correspond to a deleted file or a non-test. |
| 346 """ |
| 347 absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir()
, test_path) |
| 340 test_parser = TestParser(absolute_path, self.host) | 348 test_parser = TestParser(absolute_path, self.host) |
| 349 if not test_parser.test_doc: |
| 350 return False |
| 341 return test_parser.is_jstest() | 351 return test_parser.is_jstest() |
| OLD | NEW |