Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Pull latest revisions of a W3C test repo and make a local commit.""" | 5 """Pull latest revisions of a W3C test repo and make a local commit.""" |
| 6 | 6 |
| 7 import argparse | 7 import argparse |
| 8 import json | |
| 8 import time | 9 import time |
| 9 | 10 |
| 10 from webkitpy.common.webkit_finder import WebKitFinder | 11 from webkitpy.common.webkit_finder import WebKitFinder |
| 11 | 12 |
| 12 # Import destination directories (under LayoutTests/imported/). | 13 # Import destination directories (under LayoutTests/imported/). |
| 13 WPT_DEST_NAME = 'wpt' | 14 WPT_DEST_NAME = 'wpt' |
| 14 CSS_DEST_NAME = 'csswg-test' | 15 CSS_DEST_NAME = 'csswg-test' |
| 15 | 16 |
| 16 POLL_DELAY_SECONDS = 300 | 17 POLL_DELAY_SECONDS = 300 |
| 17 | 18 |
| 18 | 19 |
| 19 class DepsUpdater(object): | 20 class DepsUpdater(object): |
| 20 | 21 |
| 21 def __init__(self, host): | 22 def __init__(self, host): |
| 22 self.host = host | 23 self.host = host |
| 23 self.executive = host.executive | 24 self.executive = host.executive |
| 24 self.fs = host.filesystem | 25 self.fs = host.filesystem |
| 25 self.finder = WebKitFinder(self.fs) | 26 self.finder = WebKitFinder(self.fs) |
| 26 self.verbose = False | 27 self.verbose = False |
| 27 self.allow_local_commits = False | 28 self.allow_local_commits = False |
| 28 self.keep_w3c_repos_around = False | 29 self.keep_w3c_repos_around = False |
| 29 self.target = None | 30 self.target = None |
| 30 self.auto_update = False | 31 self.auto_update = False |
| 32 self.directory_dict = {} | |
| 33 self.email_list = [] | |
|
dcampb
2016/07/27 20:54:57
Why not assign these two to variables and return t
qyearsley
2016/07/27 21:38:57
I agree, if these attributes were removed and the
| |
| 31 | 34 |
| 32 def main(self, argv=None): | 35 def main(self, argv=None): |
| 33 self.parse_args(argv) | 36 self.parse_args(argv) |
| 34 | 37 |
| 35 if not self.checkout_is_okay(): | 38 if not self.checkout_is_okay(): |
| 36 return 1 | 39 return 1 |
| 37 | 40 |
| 38 self.print_('## Noting the current Chromium commit.') | 41 self.print_('## Noting the current Chromium commit.') |
| 39 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) | 42 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) |
| 40 chromium_commitish = show_ref_output.split()[0] | 43 chromium_commitish = show_ref_output.split()[0] |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 58 elif self.target == 'css': | 61 elif self.target == 'css': |
| 59 import_commitish = self.update( | 62 import_commitish = self.update( |
| 60 CSS_DEST_NAME, | 63 CSS_DEST_NAME, |
| 61 'https://chromium.googlesource.com/external/w3c/csswg-test.git') | 64 'https://chromium.googlesource.com/external/w3c/csswg-test.git') |
| 62 else: | 65 else: |
| 63 raise AssertionError("Unsupported target %s" % self.target) | 66 raise AssertionError("Unsupported target %s" % self.target) |
| 64 | 67 |
| 65 self.commit_changes_if_needed(chromium_commitish, import_commitish) | 68 self.commit_changes_if_needed(chromium_commitish, import_commitish) |
| 66 if self.auto_update: | 69 if self.auto_update: |
| 67 try_bots = self.host.builders.all_try_builder_names() | 70 try_bots = self.host.builders.all_try_builder_names() |
| 71 with open('directory_owners.json') as data_file: | |
|
qyearsley
2016/07/27 21:38:57
Would this work if the current working directory i
| |
| 72 self.parse_directory_owners(data_file) | |
| 73 self.print_('## Attempting to CC relevant parties.') | |
|
dcampb
2016/07/27 20:54:57
Just a comment change:
'Gathering directory owner
| |
| 74 _, out = self.run(['git', 'diff', 'master', '--name-only']) | |
| 75 self.parse_imported_test_changes(out, self.directory_dict) | |
| 68 self.print_('## Uploading change list.') | 76 self.print_('## Uploading change list.') |
| 69 self.check_run(['git', 'cl', 'upload', '-f', '-m', 'W3C auto test im porter']) | 77 self.check_run(['git', 'cl', 'upload', '-f', '-m', 'W3C auto test im porter'] + self.email_list) |
| 70 self.print_('## Triggering try jobs.') | 78 self.print_('## Triggering try jobs.') |
| 71 for try_bot in try_bots: | 79 for try_bot in try_bots: |
| 72 self.run(['git', 'cl', 'try', '-b', try_bot]) | 80 self.run(['git', 'cl', 'try', '-b', try_bot]) |
| 73 self.print_('## Waiting for Try Job Results') | 81 self.print_('## Waiting for Try Job Results') |
| 74 has_failing_results = False | 82 has_failing_results = False |
| 75 while True: | 83 while True: |
| 76 time.sleep(POLL_DELAY_SECONDS) | 84 time.sleep(POLL_DELAY_SECONDS) |
| 77 _, out = self.run(['git', 'cl', 'try-results']) | 85 _, out = self.run(['git', 'cl', 'try-results']) |
| 78 results = self.parse_try_job_results(out) | 86 results = self.parse_try_job_results(out) |
| 79 if results.get('Started') or results.get('Scheduled'): | 87 if results.get('Started') or results.get('Scheduled'): |
| 80 continue | 88 continue |
| 81 if results.get('Failures'): | 89 if results.get('Failures'): |
| 82 has_failing_results = True | 90 has_failing_results = True |
| 83 break | 91 break |
| 84 if has_failing_results: | 92 if has_failing_results: |
| 85 self.print_('## Adding test expectations lines to LayoutTests/Te stExpectations') | 93 self.print_('## Adding test expectations lines to LayoutTests/Te stExpectations') |
| 86 script_path = self.path_from_webkit_base('Tools', 'Scripts', 'up date-w3c-test-expectations') | 94 script_path = self.path_from_webkit_base('Tools', 'Scripts', 'up date-w3c-test-expectations') |
| 87 self.run([self.host.executable, script_path]) | 95 self.run([self.host.executable, script_path]) |
| 88 self.check_run(['git', 'commit', '-a', '-m', '\'Modified Test Ex pectations from W3C Test Auto-roller\'']) | 96 self.check_run(['git', 'commit', '-a', '-m', '\'Modified Test Ex pectations from W3C Test Auto-roller\'']) |
| 89 self.check_run(['git', 'cl', 'upload', '-m', '\'Wrote lines to T estExpectations\'']) | 97 self.check_run(['git', 'cl', 'upload', '-m', '\'Wrote lines to T estExpectations\'']) |
| 90 else: | 98 else: |
| 91 self.print_('No Failures, committing patch.') | 99 self.print_('No Failures, landing patch.') |
| 92 quit() | 100 quit() |
| 93 self.run(['git', 'cl', 'land', '-f']) | 101 self.run(['git', 'cl', 'land', '-f']) |
|
qyearsley
2016/07/27 21:38:57
Somewhat separate from this CL:
If possible, it w
| |
| 94 return 0 | 102 return 0 |
| 95 | 103 |
| 96 def parse_args(self, argv): | 104 def parse_args(self, argv): |
| 97 parser = argparse.ArgumentParser() | 105 parser = argparse.ArgumentParser() |
| 98 parser.description = __doc__ | 106 parser.description = __doc__ |
| 99 parser.add_argument('-v', '--verbose', action='store_true', | 107 parser.add_argument('-v', '--verbose', action='store_true', |
| 100 help='log what we are doing') | 108 help='log what we are doing') |
| 101 parser.add_argument('--allow-local-commits', action='store_true', | 109 parser.add_argument('--allow-local-commits', action='store_true', |
| 102 help='allow script to run even if we have local comm its') | 110 help='allow script to run even if we have local comm its') |
| 103 parser.add_argument('--keep-w3c-repos-around', action='store_true', | 111 parser.add_argument('--keep-w3c-repos-around', action='store_true', |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 line = line.strip() | 298 line = line.strip() |
| 291 if line[-1] == ':': | 299 if line[-1] == ':': |
| 292 result_type = line[:-1] | 300 result_type = line[:-1] |
| 293 sets[result_type] = set() | 301 sets[result_type] = set() |
| 294 elif line.split()[0] == 'Total:': | 302 elif line.split()[0] == 'Total:': |
| 295 break | 303 break |
| 296 else: | 304 else: |
| 297 sets[result_type].add(line.split()[0]) | 305 sets[result_type].add(line.split()[0]) |
| 298 return sets | 306 return sets |
| 299 | 307 |
| 308 def parse_imported_test_changes(self, results, directory_dict): | |
| 309 folders_changed = set() | |
| 310 for line in results.splitlines(): | |
| 311 line = line.strip('third_party/WebKit/LayoutTests/') | |
|
qyearsley
2016/07/27 21:38:56
I wonder if there's a way that we can avoid having
| |
| 312 directory_sep = line.rfind('/') | |
| 313 line = line[:directory_sep] | |
|
qyearsley
2016/07/27 21:38:56
This looks like it may be the same as:
line = s
| |
| 314 if line in directory_dict and line not in folders_changed: | |
| 315 self.email_list.append('--cc=' + directory_dict[line]) | |
| 316 folders_changed.add(line) | |
|
dcampb
2016/07/27 20:54:57
So I'm guessing this function:
1. Looks for the l
| |
| 317 | |
| 318 def parse_directory_owners(self, data_file): | |
| 319 data = json.load(data_file) | |
| 320 for dict_set in data: | |
|
dcampb
2016/07/27 20:54:57
dict_set --> directory_dictionary
| |
| 321 self.directory_dict[dict_set['directory']] = dict_set['notification- email'] | |
| 322 | |
| 300 def check_run(self, command): | 323 def check_run(self, command): |
| 301 return_code, out = self.run(command) | 324 return_code, out = self.run(command) |
| 302 if return_code: | 325 if return_code: |
| 303 raise Exception('%s failed with exit code %d.' % ' '.join(command), return_code) | 326 raise Exception('%s failed with exit code %d.' % ' '.join(command), return_code) |
| 304 return out | 327 return out |
| OLD | NEW |