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 """Fetches a copy of the latest state of a W3C test repository and commits. | 5 """Fetches a copy of the latest state of a W3C test repository and commits. |
| 6 | 6 |
| 7 If this script is given the argument --auto-update, it will also: | 7 If this script is given the argument --auto-update, it will also: |
| 8 1. Upload a CL. | 8 1. Upload a CL. |
| 9 2. Trigger try jobs and wait for them to complete. | 9 2. Trigger try jobs and wait for them to complete. |
| 10 3. Make any changes that are required for new failing tests. | 10 3. Make any changes that are required for new failing tests. |
| 11 4. Commit the CL. | 11 4. Commit the CL. |
| 12 | 12 |
| 13 If this script is given the argument --auto-update, it will also attempt to | 13 If this script is given the argument --auto-update, it will also attempt to |
| 14 upload a CL, trigger try jobs, and make any changes that are required for | 14 upload a CL, trigger try jobs, and make any changes that are required for |
| 15 new failing tests before committing. | 15 new failing tests before committing. |
| 16 """ | 16 """ |
| 17 | 17 |
| 18 import argparse | 18 import argparse |
| 19 import json | 19 import json |
| 20 import logging | 20 import logging |
| 21 import re | 21 import re |
| 22 | 22 |
| 23 from webkitpy.common.net.git_cl import GitCL | 23 from webkitpy.common.net.git_cl import GitCL |
| 24 from webkitpy.common.webkit_finder import WebKitFinder | 24 from webkitpy.common.webkit_finder import WebKitFinder |
| 25 from webkitpy.layout_tests.models.test_expectations import TestExpectations, Tes tExpectationParser | 25 from webkitpy.layout_tests.models.test_expectations import TestExpectations, Tes tExpectationParser |
| 26 from webkitpy.w3c.common import WPT_REPO_URL, CSS_REPO_URL, WPT_DEST_NAME, CSS_D EST_NAME, exportable_commits_since | |
| 27 from webkitpy.w3c.local_wpt import LocalWPT | |
| 28 from webkitpy.w3c.test_importer import TestImporter | |
| 26 from webkitpy.w3c.update_w3c_test_expectations import W3CExpectationsLineAdder | 29 from webkitpy.w3c.update_w3c_test_expectations import W3CExpectationsLineAdder |
| 27 from webkitpy.w3c.test_importer import TestImporter | |
| 28 from webkitpy.w3c.common import WPT_REPO_URL, CSS_REPO_URL, WPT_DEST_NAME, CSS_D EST_NAME | |
| 29 | 30 |
| 30 # Settings for how often to check try job results and how long to wait. | 31 # Settings for how often to check try job results and how long to wait. |
| 31 POLL_DELAY_SECONDS = 2 * 60 | 32 POLL_DELAY_SECONDS = 2 * 60 |
| 32 TIMEOUT_SECONDS = 180 * 60 | 33 TIMEOUT_SECONDS = 180 * 60 |
| 33 | 34 |
| 34 _log = logging.getLogger(__file__) | 35 _log = logging.getLogger(__file__) |
| 35 | 36 |
| 36 | 37 |
| 37 class DepsUpdater(object): | 38 class DepsUpdater(object): |
| 38 | 39 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 52 | 53 |
| 53 if not self.checkout_is_okay(options.allow_local_commits): | 54 if not self.checkout_is_okay(options.allow_local_commits): |
| 54 return 1 | 55 return 1 |
| 55 | 56 |
| 56 self.git_cl = GitCL(self.host, auth_refresh_token_json=options.auth_refr esh_token_json) | 57 self.git_cl = GitCL(self.host, auth_refresh_token_json=options.auth_refr esh_token_json) |
| 57 | 58 |
| 58 _log.info('Noting the current Chromium commit.') | 59 _log.info('Noting the current Chromium commit.') |
| 59 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) | 60 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) |
| 60 chromium_commit = show_ref_output.split()[0] | 61 chromium_commit = show_ref_output.split()[0] |
| 61 | 62 |
| 63 assert options.target in ('wpt', 'css') | |
| 64 dest_dir_name = WPT_DEST_NAME | |
| 65 repo_url = WPT_REPO_URL | |
| 66 if options.target != 'wpt': | |
| 67 dest_dir_name = CSS_DEST_NAME | |
| 68 repo_url = CSS_REPO_URL | |
| 69 | |
| 70 temp_repo_path = self.path_from_webkit_base(dest_dir_name) | |
| 71 _log.info('Cloning %s into %s.', repo_url, temp_repo_path) | |
| 72 self.run(['git', 'clone', repo_url, temp_repo_path]) | |
|
jeffcarp
2017/01/26 00:17:15
It would be nice to deduplicate the cloning code.
qyearsley
2017/01/26 00:30:07
That would be possible, although this code is also
jeffcarp
2017/01/27 02:05:41
Excellent, sgtm
| |
| 73 | |
| 62 if options.target == 'wpt': | 74 if options.target == 'wpt': |
| 63 import_commit = self.update(WPT_DEST_NAME, WPT_REPO_URL, options.kee p_w3c_repos_around, options.revision) | 75 commits = self.exportable_but_not_exported_commits(temp_repo_path) |
| 76 if commits: | |
| 77 _log.error('There were exportable but not-yet-exported commits: %r', commits) | |
| 78 _log.error('Aborting import to prevent clobbering these commits. ') | |
| 79 return 1 | |
| 80 | |
| 81 import_commit = self.update(dest_dir_name, temp_repo_path, options.keep_ w3c_repos_around, options.revision) | |
| 82 | |
| 83 if options.target == 'wpt': | |
| 64 self._copy_resources() | 84 self._copy_resources() |
| 65 elif options.target == 'css': | |
| 66 import_commit = self.update(CSS_DEST_NAME, CSS_REPO_URL, options.kee p_w3c_repos_around, options.revision) | |
| 67 else: | |
| 68 raise AssertionError("Unsupported target %s" % options.target) | |
| 69 | 85 |
| 70 has_changes = self._has_changes() | 86 has_changes = self._has_changes() |
| 71 if not has_changes: | 87 if not has_changes: |
| 72 _log.info('Done: no changes to import.') | 88 _log.info('Done: no changes to import.') |
| 73 return 0 | 89 return 0 |
| 74 | 90 |
| 75 commit_message = self._commit_message(chromium_commit, import_commit) | 91 commit_message = self._commit_message(chromium_commit, import_commit) |
| 76 self._commit_changes(commit_message) | 92 self._commit_changes(commit_message) |
| 77 _log.info('Done: changes imported and committed.') | 93 _log.info('Done: changes imported and committed.') |
| 78 | 94 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 if self.fs.exists(self.path_from_webkit_base(WPT_DEST_NAME)): | 131 if self.fs.exists(self.path_from_webkit_base(WPT_DEST_NAME)): |
| 116 _log.warning('WebKit/%s exists; aborting.', WPT_DEST_NAME) | 132 _log.warning('WebKit/%s exists; aborting.', WPT_DEST_NAME) |
| 117 return False | 133 return False |
| 118 | 134 |
| 119 if self.fs.exists(self.path_from_webkit_base(CSS_DEST_NAME)): | 135 if self.fs.exists(self.path_from_webkit_base(CSS_DEST_NAME)): |
| 120 _log.warning('WebKit/%s repo exists; aborting.', CSS_DEST_NAME) | 136 _log.warning('WebKit/%s repo exists; aborting.', CSS_DEST_NAME) |
| 121 return False | 137 return False |
| 122 | 138 |
| 123 return True | 139 return True |
| 124 | 140 |
| 141 def exportable_but_not_exported_commits(self, wpt_path): | |
| 142 """Checks for commits that might be overwritten by importing. | |
| 143 | |
| 144 Args: | |
| 145 wpt_path: The path to a local checkout of web-platform-tests. | |
| 146 | |
| 147 Returns: | |
| 148 A list of commits in the Chromium repo that are exportable | |
| 149 but not yet exported to the web-platform-tests repo. | |
| 150 """ | |
| 151 local_wpt = LocalWPT(self.host, path=wpt_path) | |
| 152 assert self.host.filesystem.exists(wpt_path) | |
| 153 _, chromium_commit = local_wpt.most_recent_chromium_commit() | |
| 154 return exportable_commits_since(chromium_commit.sha, self.host, local_wp t) | |
| 155 | |
| 125 def _copy_resources(self): | 156 def _copy_resources(self): |
| 126 """Copies resources from wpt to LayoutTests/resources. | 157 """Copies resources from wpt to LayoutTests/resources. |
| 127 | 158 |
| 128 We copy idlharness.js and testharness.js in wpt to LayoutTests/resources | 159 We copy idlharness.js and testharness.js in wpt to LayoutTests/resources |
| 129 in order to use them in non-imported tests. | 160 in order to use them in non-imported tests. |
| 130 | 161 |
| 131 If this method is changed, the lists of files expected to be identical | 162 If this method is changed, the lists of files expected to be identical |
| 132 in LayoutTests/PRESUBMIT.py should also be changed. | 163 in LayoutTests/PRESUBMIT.py should also be changed. |
| 133 """ | 164 """ |
| 134 resources_to_copy_from_wpt = [ | 165 resources_to_copy_from_wpt = [ |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 151 stages the generated MANIFEST.json in the git index, ready to commit. | 182 stages the generated MANIFEST.json in the git index, ready to commit. |
| 152 """ | 183 """ |
| 153 manifest_command = self.finder.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thirdparty', 'wpt', 'wpt', 'manifest') | 184 manifest_command = self.finder.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thirdparty', 'wpt', 'wpt', 'manifest') |
| 154 if 'css' in dest_path: | 185 if 'css' in dest_path: |
| 155 # Do nothing for csswg-test. | 186 # Do nothing for csswg-test. |
| 156 return | 187 return |
| 157 _log.info('Generating MANIFEST.json') | 188 _log.info('Generating MANIFEST.json') |
| 158 self.run([manifest_command, '--work', '--tests-root', dest_path]) | 189 self.run([manifest_command, '--work', '--tests-root', dest_path]) |
| 159 self.run(['git', 'add', self.fs.join(dest_path, 'MANIFEST.json')]) | 190 self.run(['git', 'add', self.fs.join(dest_path, 'MANIFEST.json')]) |
| 160 | 191 |
| 161 def update(self, dest_dir_name, url, keep_w3c_repos_around, revision): | 192 def update(self, dest_dir_name, temp_repo_path, keep_w3c_repos_around, revis ion): |
| 162 """Updates an imported repository. | 193 """Updates an imported repository. |
| 163 | 194 |
| 164 Args: | 195 Args: |
| 165 dest_dir_name: The destination directory name. | 196 dest_dir_name: The destination directory name. |
| 166 url: URL of the git repository. | 197 temp_repo_path: Path to local checkout of W3C test repo. |
| 167 revision: Commit hash or None. | 198 keep_w3c_repos_around: If True, the temp directory won't be cleaned up. |
| 199 revision: A W3C test repo commit hash, or None. | |
| 168 | 200 |
| 169 Returns: | 201 Returns: |
| 170 A string for the commit description "<destination>@<commitish>". | 202 A string for the commit description "<destination>@<commitish>". |
| 171 """ | 203 """ |
| 172 temp_repo_path = self.path_from_webkit_base(dest_dir_name) | |
| 173 _log.info('Cloning %s into %s.', url, temp_repo_path) | |
| 174 self.run(['git', 'clone', url, temp_repo_path]) | |
| 175 | |
| 176 if revision is not None: | 204 if revision is not None: |
| 177 _log.info('Checking out %s', revision) | 205 _log.info('Checking out %s', revision) |
| 178 self.run(['git', 'checkout', revision], cwd=temp_repo_path) | 206 self.run(['git', 'checkout', revision], cwd=temp_repo_path) |
| 179 | 207 |
| 180 self.run(['git', 'submodule', 'update', '--init', '--recursive'], cwd=te mp_repo_path) | 208 self.run(['git', 'submodule', 'update', '--init', '--recursive'], cwd=te mp_repo_path) |
| 181 | 209 |
| 182 _log.info('Noting the revision we are importing.') | 210 _log.info('Noting the revision we are importing.') |
| 183 _, show_ref_output = self.run(['git', 'show-ref', 'origin/master'], cwd= temp_repo_path) | 211 _, show_ref_output = self.run(['git', 'show-ref', 'origin/master'], cwd= temp_repo_path) |
| 184 master_commitish = show_ref_output.split()[0] | 212 master_commitish = show_ref_output.split()[0] |
| 185 | 213 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 """Returns a dict mapping source to dest name for layout tests that have been renamed.""" | 479 """Returns a dict mapping source to dest name for layout tests that have been renamed.""" |
| 452 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff- filter=R', '--name-status']) | 480 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff- filter=R', '--name-status']) |
| 453 renamed_tests = {} | 481 renamed_tests = {} |
| 454 for line in out.splitlines(): | 482 for line in out.splitlines(): |
| 455 _, source_path, dest_path = line.split() | 483 _, source_path, dest_path = line.split() |
| 456 source_test = self.finder.layout_test_name(source_path) | 484 source_test = self.finder.layout_test_name(source_path) |
| 457 dest_test = self.finder.layout_test_name(dest_path) | 485 dest_test = self.finder.layout_test_name(dest_path) |
| 458 if source_test and dest_test: | 486 if source_test and dest_test: |
| 459 renamed_tests[source_test] = dest_test | 487 renamed_tests[source_test] = dest_test |
| 460 return renamed_tests | 488 return renamed_tests |
| OLD | NEW |