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 """Updates layout test expectations and baselines when updating w3c tests. | 5 """Updates layout test expectations and baselines when updating w3c tests. |
6 | 6 |
7 Specifically, this class fetches results from try bots for the current CL, then | 7 Specifically, this class fetches results from try bots for the current CL, then |
8 (1) downloads new baseline files for any tests that can be rebaselined, and | 8 (1) downloads new baseline files for any tests that can be rebaselined, and |
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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 412 |
413 Args: | 413 Args: |
414 test_results: A dictionary of failing test results, mapping tests | 414 test_results: A dictionary of failing test results, mapping tests |
415 to platforms to result dicts. | 415 to platforms to result dicts. |
416 | 416 |
417 Returns: | 417 Returns: |
418 A pair: A set of tests to be rebaselined, and a modified copy of | 418 A pair: A set of tests to be rebaselined, and a modified copy of |
419 the test results dictionary. The tests to be rebaselined should | 419 the test results dictionary. The tests to be rebaselined should |
420 include testharness.js tests that failed due to a baseline mismatch. | 420 include testharness.js tests that failed due to a baseline mismatch. |
421 """ | 421 """ |
422 test_results = copy.deepcopy(test_results) | 422 new_test_results = copy.deepcopy(test_results) |
423 tests_to_rebaseline = set() | 423 tests_to_rebaseline = set() |
424 for test_path in test_results: | 424 for test_path in test_results: |
425 if not (self.is_js_test(test_path) and test_results.get(test_path)): | 425 for platform, result in test_results[test_path].iteritems(): |
426 continue | 426 if self.can_rebaseline(test_path, result): |
427 for platform in test_results[test_path].keys(): | 427 del new_test_results[test_path][platform] |
428 if test_results[test_path][platform]['actual'] not in ['CRASH',
'TIMEOUT']: | |
429 del test_results[test_path][platform] | |
430 tests_to_rebaseline.add(test_path) | 428 tests_to_rebaseline.add(test_path) |
431 return sorted(tests_to_rebaseline), test_results | 429 return sorted(tests_to_rebaseline), new_test_results |
| 430 |
| 431 def can_rebaseline(self, test_path, result): |
| 432 return (self.is_js_test(test_path) and |
| 433 result['actual'] not in ('CRASH', 'TIMEOUT')) |
432 | 434 |
433 def is_js_test(self, test_path): | 435 def is_js_test(self, test_path): |
434 """Checks whether a given file is a testharness.js test. | 436 """Checks whether a given file is a testharness.js test. |
435 | 437 |
| 438 TODO(qyearsley): This may not behave how we want it to for virtual tests
. |
| 439 TODO(qyearsley): Avoid using TestParser; maybe this should use |
| 440 Port.test_type, or Port.reference_files to see whether it's not |
| 441 a reference test? |
| 442 |
436 Args: | 443 Args: |
437 test_path: A file path relative to the layout tests directory. | 444 test_path: A file path relative to the layout tests directory. |
438 This might correspond to a deleted file or a non-test. | 445 This might correspond to a deleted file or a non-test. |
439 """ | 446 """ |
440 absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir()
, test_path) | 447 absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir()
, test_path) |
441 test_parser = TestParser(absolute_path, self.host) | 448 test_parser = TestParser(absolute_path, self.host) |
442 if not test_parser.test_doc: | 449 if not test_parser.test_doc: |
443 return False | 450 return False |
444 return test_parser.is_jstest() | 451 return test_parser.is_jstest() |
445 | 452 |
446 def _get_try_bots(self): | 453 def _get_try_bots(self): |
447 return self.host.builders.all_try_builder_names() | 454 return self.host.builders.all_try_builder_names() |
OLD | NEW |