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 script to modify TestExpectations lines based layout test failures in try j obs. | 5 """A script to modify TestExpectations lines based layout test failures in try j obs. |
| 6 | 6 |
| 7 This script outputs a list of test expectation lines to add to a 'TestExpectatio ns' file | 7 This script outputs a list of test expectation lines to add to a 'TestExpectatio ns' file |
| 8 by retrieving the try job results for the current CL. | 8 by retrieving the try job results for the current CL. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import logging | 11 import logging |
| 12 | 12 |
| 13 from webkitpy.common.net.buildbot import BuildBot | 13 from webkitpy.common.net.buildbot import BuildBot |
| 14 from webkitpy.w3c.test_parser import TestParser | |
| 15 from webkitpy.common.webkit_finder import WebKitFinder | |
|
qyearsley
2016/07/29 20:59:44
Remember to sort the new imports
dcampb
2016/08/02 18:02:12
done
| |
| 14 from webkitpy.common.net import rietveld | 16 from webkitpy.common.net import rietveld |
| 15 | 17 |
| 16 | 18 |
| 17 _log = logging.getLogger(__name__) | 19 _log = logging.getLogger(__name__) |
| 18 | 20 |
| 19 | 21 |
| 20 def main(host, port): | 22 def main(host, port): |
| 21 expectations_file = port.path_to_generic_test_expectations_file() | 23 expectations_file = port.path_to_generic_test_expectations_file() |
| 22 expectations_line_adder = W3CExpectationsLineAdder(host) | 24 expectations_line_adder = W3CExpectationsLineAdder(host) |
| 23 issue_number = expectations_line_adder.get_issue_number() | 25 issue_number = expectations_line_adder.get_issue_number() |
| 24 try_bots = expectations_line_adder.get_try_bots() | 26 try_bots = expectations_line_adder.get_try_bots() |
| 25 try_jobs = rietveld.latest_try_jobs(issue_number, try_bots, host.web) | 27 try_jobs = rietveld.latest_try_jobs(issue_number, try_bots, host.web) |
| 26 test_expectations = {} | 28 test_expectations = {} |
| 27 if not try_jobs: | 29 if not try_jobs: |
| 28 print 'No Try Job information was collected.' | 30 print 'No Try Job information was collected.' |
| 29 return 1 | 31 return 1 |
| 30 for job in try_jobs: | 32 for job in try_jobs: |
| 31 platform_results = expectations_line_adder.get_failing_results_dict(Buil dBot(), job.builder_name, job.build_number) | 33 platform_results = expectations_line_adder.get_failing_results_dict(Buil dBot(), job.builder_name, job.build_number) |
| 32 test_expectations = expectations_line_adder.merge_dicts(test_expectation s, platform_results) | 34 test_expectations = expectations_line_adder.merge_dicts(test_expectation s, platform_results) |
| 33 for test_name, platform_result in test_expectations.iteritems(): | 35 for test_name, platform_result in test_expectations.iteritems(): |
| 34 test_expectations[test_name] = expectations_line_adder.merge_same_valued _keys(platform_result) | 36 test_expectations[test_name] = expectations_line_adder.merge_same_valued _keys(platform_result) |
| 37 test_expectations = expectations_line_adder.get_expected_txt_files(test_expe ctations) | |
| 35 test_expectation_lines = expectations_line_adder.create_line_list(test_expec tations) | 38 test_expectation_lines = expectations_line_adder.create_line_list(test_expec tations) |
| 36 expectations_line_adder.write_to_test_expectations(host, expectations_file, test_expectation_lines) | 39 expectations_line_adder.write_to_test_expectations(host, expectations_file, test_expectation_lines) |
| 37 | 40 |
| 38 | 41 |
| 39 class W3CExpectationsLineAdder(object): | 42 class W3CExpectationsLineAdder(object): |
| 40 | 43 |
| 41 def __init__(self, host): | 44 def __init__(self, host): |
| 42 self._host = host | 45 self._host = host |
| 43 self.filesystem = host.filesystem | 46 self.filesystem = host.filesystem |
| 44 | 47 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 all_lines += str(line) + '\n' | 264 all_lines += str(line) + '\n' |
| 262 all_lines = all_lines[:-1] | 265 all_lines = all_lines[:-1] |
| 263 if w3c_comment_line_index == -1: | 266 if w3c_comment_line_index == -1: |
| 264 file_contents += '\n%s\n' % comment_line | 267 file_contents += '\n%s\n' % comment_line |
| 265 file_contents += all_lines | 268 file_contents += all_lines |
| 266 else: | 269 else: |
| 267 end_of_comment_line = (file_contents[w3c_comment_line_index:].find(' \n')) + w3c_comment_line_index | 270 end_of_comment_line = (file_contents[w3c_comment_line_index:].find(' \n')) + w3c_comment_line_index |
| 268 new_data = file_contents[: end_of_comment_line + 1] + all_lines + fi le_contents[end_of_comment_line:] | 271 new_data = file_contents[: end_of_comment_line + 1] + all_lines + fi le_contents[end_of_comment_line:] |
| 269 file_contents = new_data | 272 file_contents = new_data |
| 270 host.filesystem.write_text_file(path, file_contents) | 273 host.filesystem.write_text_file(path, file_contents) |
| 274 | |
| 275 def get_expected_txt_files(self, tests_results): | |
| 276 """Gets -expected.txt files. | |
| 277 | |
| 278 Invokes WebKit-Patch RebaselineFromTryJobs in order | |
|
qyearsley
2016/07/29 20:59:45
WebKit-Patch RebaselineFromTryJobs -> webkit-patch
dcampb
2016/08/01 17:26:02
done
| |
| 279 to download new -expected.txt files for testharness.js | |
| 280 tests that did not Crash or Timeout. Afterwords, the platform- | |
|
qyearsley
2016/07/29 20:59:45
Afterwards -> Afterwards
or "Then, ..."
dcampb
2016/08/01 17:26:02
done
| |
| 281 specific test is removed from the overall failure test dictionary. | |
| 282 | |
| 283 Args: | |
| 284 tests_results: A dictionary that maps test name to platforms to | |
| 285 test results. | |
| 286 | |
| 287 Returns: | |
| 288 An updated tests_results dictionary without the platform-specific te st- | |
| 289 harness.js tests that required new baselines to be downloaded from | |
| 290 WebKit-Patch RebaselineFromTryJobs. | |
|
qyearsley
2016/07/29 20:59:44
WebKit-Patch RebaselineFromTryJobs -> webkit-patch
dcampb
2016/08/01 17:26:02
done
| |
| 291 """ | |
| 292 finder = WebKitFinder(self._host.filesystem) | |
| 293 root = finder.chromium_base() | |
| 294 layout_tests_relative_path = self._host.filesystem.relpath(finder.layout _tests_dir(), root) | |
| 295 webkit_base = finder.webkit_base() | |
| 296 crash_or_timeout = ['CRASH', 'TIMEOUT'] | |
|
qyearsley
2016/07/29 20:59:45
The fewer variables there are in a function, then
dcampb
2016/08/01 17:26:02
noted
dcampb
2016/08/01 17:26:02
noted
| |
| 297 tests_to_rebaseline = [] | |
| 298 tests = self._host.executive.run_command(['git', 'diff', 'master', '--na me-only']) | |
| 299 for test_dir in tests.splitlines(): | |
| 300 absolute_path = self._host.filesystem.join(root, test_dir) | |
| 301 test_parser = TestParser(None, absolute_path) | |
| 302 is_js_test = test_parser.is_jstest() | |
| 303 if is_js_test: | |
| 304 test_path = self._host.filesystem.relpath(test_dir, layout_tests _relative_path) | |
| 305 try: | |
| 306 for platform in tests_results[test_path]: | |
| 307 if tests_results[test_path][platform]['actual'] not in c rash_or_timeout: | |
| 308 del tests_results[test_path][platform] | |
| 309 tests_to_rebaseline.append(test_path) | |
| 310 # TODO(dcampb): Remove once trybots are all running layout | |
| 311 # Was used for testing | |
|
qyearsley
2016/07/29 20:59:45
I'm not quite sure what this comment means now
dcampb
2016/08/01 17:26:02
removed it now. It was because I had some newly im
| |
| 312 except KeyError: | |
| 313 pass | |
| 314 if tests_to_rebaseline: | |
| 315 webkit_patch = self._host.filesystem.join(root, webkit_base, finder. path_to_script('webkit-patch')) | |
| 316 self._host.executive.run_command(['python', webkit_patch, | |
| 317 'rebaseline-from-try-jobs', '-v', | |
| 318 ' '.join(tests_to_rebaseline)]) | |
|
qyearsley
2016/07/29 20:59:45
Each of the tests is a separate arg, so the input
dcampb
2016/08/01 17:26:02
tests_to_rebaseline is a of test names. This way I
qyearsley
2016/08/01 18:33:18
Concatenating the start of the argument list with
dcampb
2016/08/02 18:02:12
okay, I see. Changes made
| |
| 319 return tests_results | |
| OLD | NEW |