Chromium Code Reviews| Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py |
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py |
| index d56f1682c31ce8048e74391adff42f7825775c3c..66165d1d920633c5701f6a1e7840072b99ce551a 100644 |
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py |
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py |
| @@ -5,6 +5,7 @@ |
| """Pull latest revisions of a W3C test repo and make a local commit.""" |
| import argparse |
| +import time |
| from webkitpy.common.webkit_finder import WebKitFinder |
| @@ -12,6 +13,9 @@ from webkitpy.common.webkit_finder import WebKitFinder |
| WPT_DEST_NAME = 'wpt' |
| CSS_DEST_NAME = 'csswg-test' |
| +# Used for time.sleep(). |
| +FIVE_MINUTES = 300 |
|
qyearsley
2016/07/06 22:13:29
FIVE_MINUTES is a bad name because if you ever cha
|
| + |
| class DepsUpdater(object): |
| @@ -24,6 +28,7 @@ class DepsUpdater(object): |
| self.allow_local_commits = False |
| self.keep_w3c_repos_around = False |
| self.target = None |
| + self.auto_update = False |
| def main(self, argv=None): |
| self.parse_args(argv) |
| @@ -60,6 +65,18 @@ class DepsUpdater(object): |
| self.commit_changes_if_needed(chromium_commitish, import_commitish) |
| + if self.auto_update: |
| + self.run(['git', 'cl', 'upload', '-f']) |
| + self.run(['git', 'cl', 'set-commit', '-d']) |
|
qyearsley
2016/07/06 22:13:29
If you change '-d' to '--dry-run', then it may be
|
| + while True: |
| + time.sleep(FIVE_MINUTES) |
| + _, out = self.run(['git', 'cl', 'try-results']) |
| + results = self.parse_try_job_results(out) |
| + if results['Started'] != set([]) or results['Scheduled'] != set([]): |
| + continue |
| + if results['Failures'] != set([]): |
| + return 1 |
| + break |
| return 0 |
| def parse_args(self, argv): |
| @@ -73,12 +90,15 @@ class DepsUpdater(object): |
| help='leave the w3c repos around that were imported previously.') |
| parser.add_argument('target', choices=['css', 'wpt'], |
| help='Target repository. "css" for csswg-test, "wpt" for web-platform-tests.') |
| + parser.add_argument('--auto-update', action='store_true', |
| + help='uploads CL and initiates commit queue.') |
| args = parser.parse_args(argv) |
| self.allow_local_commits = args.allow_local_commits |
| self.keep_w3c_repos_around = args.keep_w3c_repos_around |
| self.verbose = args.verbose |
| self.target = args.target |
| + self.auto_update = args.auto_update |
| def checkout_is_okay(self): |
| git_diff_retcode, _ = self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_failure=False) |
| @@ -222,3 +242,37 @@ class DepsUpdater(object): |
| def print_(self, msg): |
| self.host.print_(msg) |
| + |
| + def parse_try_job_results(self, results): |
| + """Parses try job results from Rietveld. |
| + |
| + Turns the output from git cl try-results into a usable format. |
| + |
| + Args: |
| + results: The stdout obtained by running git cl try-results |
| + |
| + Returns: |
| + A dict mapping a specified set of results to the builders that |
| + obtained those results. The list is builders is represented as |
| + a set and any bots in bot failures and successes set are removed |
| + from failures |
| + |
| + Raises: |
| + AttributeError: An unexpected result was found |
| + """ |
| + sets = {} |
| + for line in results.splitlines(): |
| + line.strip() |
| + print line |
| + if line[len(line) - 1] == ':': |
| + result_type = line[:len(line) - 1] |
| + sets[result_type] = set() |
| + elif line.split()[0] == 'Total:': |
| + break |
| + else: |
| + sets[result_type].add(line.split()[0]) |
| + print sets |
| + sets['Failures'] -= sets['Successes'] |
| + sets['Started'] -= sets['Successes'] |
| + sets['Started'] -= sets['Failures'] |
| + return sets |