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 time | |
| 9 import sys | |
| 8 | 10 |
| 9 from webkitpy.common.webkit_finder import WebKitFinder | 11 from webkitpy.common.webkit_finder import WebKitFinder |
| 10 | 12 |
| 11 # Import destination directories (under LayoutTests/imported/). | |
|
qyearsley
2016/07/01 17:40:40
Why is this deleted?
| |
| 12 WPT_DEST_NAME = 'wpt' | 13 WPT_DEST_NAME = 'wpt' |
| 13 CSS_DEST_NAME = 'csswg-test' | 14 CSS_DEST_NAME = 'csswg-test' |
| 14 | 15 |
| 15 | 16 |
| 16 class DepsUpdater(object): | 17 class DepsUpdater(object): |
| 17 | 18 |
| 18 def __init__(self, host): | 19 def __init__(self, host): |
| 19 self.host = host | 20 self.host = host |
| 20 self.executive = host.executive | 21 self.executive = host.executive |
| 21 self.fs = host.filesystem | 22 self.fs = host.filesystem |
| 22 self.finder = WebKitFinder(self.fs) | 23 self.finder = WebKitFinder(self.fs) |
| 23 self.verbose = False | 24 self.verbose = False |
| 24 self.allow_local_commits = False | 25 self.allow_local_commits = False |
| 25 self.keep_w3c_repos_around = False | 26 self.keep_w3c_repos_around = False |
| 26 self.target = None | 27 self.target = None |
| 28 self.auto_update = False | |
| 27 | 29 |
| 28 def main(self, argv=None): | 30 def main(self, argv=None): |
| 29 self.parse_args(argv) | 31 self.parse_args(argv) |
| 30 | 32 |
| 31 if not self.checkout_is_okay(): | 33 if not self.checkout_is_okay(): |
| 32 return 1 | 34 return 1 |
| 33 | 35 |
| 34 self.print_('## Noting the current Chromium commit.') | 36 self.print_('## Noting the current Chromium commit.') |
| 35 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) | 37 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) |
| 36 chromium_commitish = show_ref_output.split()[0] | 38 chromium_commitish = show_ref_output.split()[0] |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 53 | 55 |
| 54 elif self.target == 'css': | 56 elif self.target == 'css': |
| 55 import_commitish = self.update( | 57 import_commitish = self.update( |
| 56 CSS_DEST_NAME, | 58 CSS_DEST_NAME, |
| 57 'https://chromium.googlesource.com/external/w3c/csswg-test.git') | 59 'https://chromium.googlesource.com/external/w3c/csswg-test.git') |
| 58 else: | 60 else: |
| 59 raise AssertionError("Unsupported target %s" % self.target) | 61 raise AssertionError("Unsupported target %s" % self.target) |
| 60 | 62 |
| 61 self.commit_changes_if_needed(chromium_commitish, import_commitish) | 63 self.commit_changes_if_needed(chromium_commitish, import_commitish) |
| 62 | 64 |
| 65 if self.auto_update: | |
| 66 self.run(['git', 'cl', 'upload', '-f']) | |
| 67 self.run(['git', 'cl', 'set-commit']) | |
| 68 while True: | |
| 69 ret_code, out = self.run(['git', 'cl', 'try-results']) | |
| 70 del ret_code | |
|
qyearsley
2016/07/01 17:40:39
If a function returns a pair, but you don't care a
| |
| 71 results = self.parse_try_job_results(out) | |
| 72 if results['Started'] != set([]): | |
| 73 time.sleep(300) | |
|
qyearsley
2016/07/01 17:40:39
In general whenever you see a literal number (othe
| |
| 74 continue | |
| 75 if results['Failures'] != set([]): | |
| 76 sys.exit(2) | |
|
qyearsley
2016/07/01 17:40:40
Does exit code 2 have any particular significance?
| |
| 77 break | |
| 63 return 0 | 78 return 0 |
|
qyearsley
2016/07/01 17:40:40
Some cases to think about:
- If there are no sta
| |
| 64 | 79 |
| 65 def parse_args(self, argv): | 80 def parse_args(self, argv): |
| 66 parser = argparse.ArgumentParser() | 81 parser = argparse.ArgumentParser() |
| 67 parser.description = __doc__ | 82 parser.description = __doc__ |
| 68 parser.add_argument('-v', '--verbose', action='store_true', | 83 parser.add_argument('-v', '--verbose', action='store_true', |
| 69 help='log what we are doing') | 84 help='log what we are doing') |
| 70 parser.add_argument('--allow-local-commits', action='store_true', | 85 parser.add_argument('--allow-local-commits', action='store_true', |
| 71 help='allow script to run even if we have local comm its') | 86 help='allow script to run even if we have local comm its') |
| 72 parser.add_argument('--keep-w3c-repos-around', action='store_true', | 87 parser.add_argument('--keep-w3c-repos-around', action='store_true', |
| 73 help='leave the w3c repos around that were imported previously.') | 88 help='leave the w3c repos around that were imported previously.') |
| 74 parser.add_argument('target', choices=['css', 'wpt'], | 89 parser.add_argument('target', choices=['css', 'wpt'], |
| 75 help='Target repository. "css" for csswg-test, "wpt " for web-platform-tests.') | 90 help='Target repository. "css" for csswg-test, "wpt " for web-platform-tests.') |
| 91 parser.add_argument('--auto-update', action='store_true', | |
|
qyearsley
2016/07/01 17:40:40
The CL description says "--auto-import" and this s
| |
| 92 help='uploads cl and initiates commit queue.') | |
|
qyearsley
2016/07/01 17:40:40
cl -> CL
| |
| 76 | 93 |
| 77 args = parser.parse_args(argv) | 94 args = parser.parse_args(argv) |
| 78 self.allow_local_commits = args.allow_local_commits | 95 self.allow_local_commits = args.allow_local_commits |
| 79 self.keep_w3c_repos_around = args.keep_w3c_repos_around | 96 self.keep_w3c_repos_around = args.keep_w3c_repos_around |
| 80 self.verbose = args.verbose | 97 self.verbose = args.verbose |
| 81 self.target = args.target | 98 self.target = args.target |
| 99 self.auto_update = args.auto_update | |
| 82 | 100 |
| 83 def checkout_is_okay(self): | 101 def checkout_is_okay(self): |
| 84 git_diff_retcode, _ = self.run(['git', 'diff', '--quiet', 'HEAD'], exit_ on_failure=False) | 102 git_diff_retcode, _ = self.run(['git', 'diff', '--quiet', 'HEAD'], exit_ on_failure=False) |
| 85 if git_diff_retcode: | 103 if git_diff_retcode: |
| 86 self.print_('## Checkout is dirty; aborting.') | 104 self.print_('## Checkout is dirty; aborting.') |
| 87 return False | 105 return False |
| 88 | 106 |
| 89 local_commits = self.run(['git', 'log', '--oneline', 'origin/master..HEA D'])[1] | 107 local_commits = self.run(['git', 'log', '--oneline', 'origin/master..HEA D'])[1] |
| 90 if local_commits and not self.allow_local_commits: | 108 if local_commits and not self.allow_local_commits: |
| 91 self.print_('## Checkout has local commits; aborting. Use --allow-lo cal-commits to allow this.') | 109 self.print_('## Checkout has local commits; aborting. Use --allow-lo cal-commits to allow this.') |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 dest = self.path_from_webkit_base(*comps) | 233 dest = self.path_from_webkit_base(*comps) |
| 216 if self.verbose: | 234 if self.verbose: |
| 217 self.print_('rm -fr %s' % dest) | 235 self.print_('rm -fr %s' % dest) |
| 218 self.fs.rmtree(dest) | 236 self.fs.rmtree(dest) |
| 219 | 237 |
| 220 def path_from_webkit_base(self, *comps): | 238 def path_from_webkit_base(self, *comps): |
| 221 return self.finder.path_from_webkit_base(*comps) | 239 return self.finder.path_from_webkit_base(*comps) |
| 222 | 240 |
| 223 def print_(self, msg): | 241 def print_(self, msg): |
| 224 self.host.print_(msg) | 242 self.host.print_(msg) |
| 243 | |
| 244 def parse_try_job_results(self, results): | |
|
qyearsley
2016/07/01 17:40:40
You could consider adding a docstring for this fun
| |
| 245 fields = ['Successes:', 'Started:', 'Scheduled:', 'Failures:'] | |
| 246 sets = {'Successes': set(), 'Started': set(), 'Scheduled': set(), 'Failu res': set()} | |
| 247 for line in results.splitlines(): | |
| 248 if line in fields: | |
| 249 temp = line[:len(line)] | |
|
qyearsley
2016/07/01 17:40:40
`temp` isn't a very meaningful name (http://c2.com
| |
| 250 else: | |
| 251 sets[temp].add(line.split()[1]) | |
|
qyearsley
2016/07/01 17:40:40
At the bottom of the output it also prints
"Total:
| |
| 252 sets['Failures'] -= sets['Successes'] | |
| 253 return sets | |
| OLD | NEW |