| 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 re | 8 import re |
| 9 | 9 |
| 10 from webkitpy.common.webkit_finder import WebKitFinder | 10 from webkitpy.common.webkit_finder import WebKitFinder |
| 11 | 11 |
| 12 # Import destination directories (under LayoutTests/imported/). |
| 13 WPT_DEST_NAME = 'wpt' |
| 14 CSS_DEST_NAME = 'csswg-test' |
| 15 |
| 12 | 16 |
| 13 class DepsUpdater(object): | 17 class DepsUpdater(object): |
| 14 | 18 |
| 15 def __init__(self, host): | 19 def __init__(self, host): |
| 16 self.host = host | 20 self.host = host |
| 17 self.executive = host.executive | 21 self.executive = host.executive |
| 18 self.fs = host.filesystem | 22 self.fs = host.filesystem |
| 19 self.finder = WebKitFinder(self.fs) | 23 self.finder = WebKitFinder(self.fs) |
| 20 self.verbose = False | 24 self.verbose = False |
| 21 self.allow_local_commits = False | 25 self.allow_local_commits = False |
| 22 self.keep_w3c_repos_around = False | 26 self.keep_w3c_repos_around = False |
| 23 | 27 |
| 24 def main(self, argv=None): | 28 def main(self, argv=None): |
| 25 self.parse_args(argv) | 29 self.parse_args(argv) |
| 26 | 30 |
| 27 self.cd('') | 31 self.cd('') |
| 28 if not self.checkout_is_okay(): | 32 if not self.checkout_is_okay(): |
| 29 return 1 | 33 return 1 |
| 30 | 34 |
| 31 self.print_('## noting the current Chromium commitish') | 35 self.print_('## noting the current Chromium commitish') |
| 32 chromium_commitish = self.run(['git', 'show-ref', 'HEAD'])[1].split()[0] | 36 chromium_commitish = self.run(['git', 'show-ref', 'HEAD'])[1].split()[0] |
| 33 | 37 |
| 34 if self.target == 'wpt': | 38 if self.target == 'wpt': |
| 35 import_commitish = self.update('web-platform-tests', | 39 import_commitish = self.update( |
| 36 'https://chromium.googlesource.com/ex
ternal/w3c/web-platform-tests.git') | 40 WPT_DEST_NAME, |
| 41 'https://chromium.googlesource.com/external/w3c/web-platform-tes
ts.git') |
| 37 | 42 |
| 38 for resource in ['testharnessreport.js', 'vendor-prefix.js']: | 43 for resource in ['testharnessreport.js', 'vendor-prefix.js']: |
| 39 source = self.path_from_webkit_base('LayoutTests', 'resources',
resource) | 44 source = self.path_from_webkit_base('LayoutTests', 'resources',
resource) |
| 40 destination = self.path_from_webkit_base('LayoutTests', 'importe
d', 'web-platform-tests', 'resources', resource) | 45 destination = self.path_from_webkit_base('LayoutTests', 'importe
d', WPT_DEST_NAME, 'resources', resource) |
| 41 self.copyfile(source, destination) | 46 self.copyfile(source, destination) |
| 42 self.run(['git', 'add', destination]) | 47 self.run(['git', 'add', destination]) |
| 43 | 48 |
| 44 elif self.target == 'css': | 49 elif self.target == 'css': |
| 45 import_commitish = self.update('csswg-test', | 50 import_commitish = self.update( |
| 46 'https://chromium.googlesource.com/ex
ternal/w3c/csswg-test.git') | 51 CSS_DEST_NAME, |
| 52 'https://chromium.googlesource.com/external/w3c/csswg-test.git') |
| 47 else: | 53 else: |
| 48 raise AssertionError("Unsupported target %s" % self.target) | 54 raise AssertionError("Unsupported target %s" % self.target) |
| 49 | 55 |
| 50 self.commit_changes_if_needed(chromium_commitish, import_commitish) | 56 self.commit_changes_if_needed(chromium_commitish, import_commitish) |
| 51 | 57 |
| 52 return 0 | 58 return 0 |
| 53 | 59 |
| 54 def parse_args(self, argv): | 60 def parse_args(self, argv): |
| 55 parser = argparse.ArgumentParser() | 61 parser = argparse.ArgumentParser() |
| 56 parser.description = __doc__ | 62 parser.description = __doc__ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 72 def checkout_is_okay(self): | 78 def checkout_is_okay(self): |
| 73 if self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_failure=False)[0
]: | 79 if self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_failure=False)[0
]: |
| 74 self.print_('## checkout is dirty, aborting') | 80 self.print_('## checkout is dirty, aborting') |
| 75 return False | 81 return False |
| 76 | 82 |
| 77 local_commits = self.run(['git', 'log', '--oneline', 'origin/master..HEA
D'])[1] | 83 local_commits = self.run(['git', 'log', '--oneline', 'origin/master..HEA
D'])[1] |
| 78 if local_commits and not self.allow_local_commits: | 84 if local_commits and not self.allow_local_commits: |
| 79 self.print_('## checkout has local commits, aborting') | 85 self.print_('## checkout has local commits, aborting') |
| 80 return False | 86 return False |
| 81 | 87 |
| 82 if self.fs.exists(self.path_from_webkit_base('web-platform-tests')): | 88 if self.fs.exists(self.path_from_webkit_base(WPT_DEST_NAME)): |
| 83 self.print_('## web-platform-tests repo exists, aborting') | 89 self.print_('## web-platform-tests repo exists, aborting') |
| 84 return False | 90 return False |
| 85 | 91 |
| 86 if self.fs.exists(self.path_from_webkit_base('csswg-test')): | 92 if self.fs.exists(self.path_from_webkit_base(CSS_DEST_NAME)): |
| 87 self.print_('## csswg-test repo exists, aborting') | 93 self.print_('## csswg-test repo exists, aborting') |
| 88 return False | 94 return False |
| 89 | 95 |
| 90 return True | 96 return True |
| 91 | 97 |
| 92 def update(self, repo, url): | 98 def update(self, dest, url): |
| 93 self.print_('## cloning %s' % repo) | 99 """Updates an imported repository. |
| 100 |
| 101 Args: |
| 102 dest: The destination directory name. |
| 103 url: URL of the git repository. |
| 104 |
| 105 Returns: |
| 106 A string for the commit description "<destination>@<commitish>". |
| 107 """ |
| 108 self.print_('## cloning %s into %s' % (url, dest)) |
| 94 self.cd('') | 109 self.cd('') |
| 95 self.run(['git', 'clone', url]) | 110 self.run(['git', 'clone', url, dest]) |
| 96 self.cd(re.compile('.*/([^/]+)\.git').match(url).group(1)) | 111 |
| 112 self.cd(dest) |
| 97 self.run(['git', 'submodule', 'update', '--init', '--recursive']) | 113 self.run(['git', 'submodule', 'update', '--init', '--recursive']) |
| 98 | 114 |
| 99 self.print_('## noting the revision we are importing') | 115 self.print_('## noting the revision we are importing') |
| 100 master_commitish = self.run(['git', 'show-ref', 'origin/master'])[1].spl
it()[0] | 116 master_commitish = self.run(['git', 'show-ref', 'origin/master'])[1].spl
it()[0] |
| 101 | 117 |
| 102 self.print_('## cleaning out tests from LayoutTests/imported/%s' % repo) | 118 self.print_('## cleaning out tests from LayoutTests/imported/%s' % dest) |
| 103 dest_repo = self.path_from_webkit_base('LayoutTests', 'imported', repo) | 119 dest_repo = self.path_from_webkit_base('LayoutTests', 'imported', dest) |
| 104 files_to_delete = self.fs.files_under(dest_repo, file_filter=self.is_not
_baseline) | 120 files_to_delete = self.fs.files_under(dest_repo, file_filter=self.is_not
_baseline) |
| 105 for subpath in files_to_delete: | 121 for subpath in files_to_delete: |
| 106 self.remove('LayoutTests', 'imported', subpath) | 122 self.remove('LayoutTests', 'imported', subpath) |
| 107 | 123 |
| 108 self.print_('## importing the tests') | 124 self.print_('## importing the tests') |
| 109 src_repo = self.path_from_webkit_base(repo) | 125 src_repo = self.path_from_webkit_base(dest) |
| 110 import_path = self.path_from_webkit_base('Tools', 'Scripts', 'import-w3c
-tests') | 126 import_path = self.path_from_webkit_base('Tools', 'Scripts', 'import-w3c
-tests') |
| 111 self.run([self.host.executable, import_path, '-d', 'imported', src_repo]
) | 127 self.run([self.host.executable, import_path, '-d', 'imported', src_repo]
) |
| 112 | 128 |
| 113 self.cd('') | 129 self.cd('') |
| 114 self.run(['git', 'add', '--all', 'LayoutTests/imported/%s' % repo]) | 130 self.run(['git', 'add', '--all', 'LayoutTests/imported/%s' % dest]) |
| 115 | 131 |
| 116 self.print_('## deleting manual tests') | 132 self.print_('## deleting manual tests') |
| 117 files_to_delete = self.fs.files_under(dest_repo, file_filter=self.is_man
ual_test) | 133 files_to_delete = self.fs.files_under(dest_repo, file_filter=self.is_man
ual_test) |
| 118 for subpath in files_to_delete: | 134 for subpath in files_to_delete: |
| 119 self.remove('LayoutTests', 'imported', subpath) | 135 self.remove('LayoutTests', 'imported', subpath) |
| 120 | 136 |
| 121 self.print_('## deleting any orphaned baselines') | 137 self.print_('## deleting any orphaned baselines') |
| 122 previous_baselines = self.fs.files_under(dest_repo, file_filter=self.is_
baseline) | 138 previous_baselines = self.fs.files_under(dest_repo, file_filter=self.is_
baseline) |
| 123 for subpath in previous_baselines: | 139 for subpath in previous_baselines: |
| 124 full_path = self.fs.join(dest_repo, subpath) | 140 full_path = self.fs.join(dest_repo, subpath) |
| 125 if self.fs.glob(full_path.replace('-expected.txt', '*')) == [full_pa
th]: | 141 if self.fs.glob(full_path.replace('-expected.txt', '*')) == [full_pa
th]: |
| 126 self.fs.remove(full_path) | 142 self.fs.remove(full_path) |
| 127 | 143 |
| 128 if not self.keep_w3c_repos_around: | 144 if not self.keep_w3c_repos_around: |
| 129 self.print_('## deleting %s repo' % repo) | 145 self.print_('## deleting %s repo directory' % dest) |
| 130 self.cd('') | 146 self.cd('') |
| 131 self.rmtree(repo) | 147 self.rmtree(repo) |
| 132 | 148 |
| 133 return '%s@%s' % (repo, master_commitish) | 149 return '%s@%s' % (dest, master_commitish) |
| 134 | 150 |
| 135 def commit_changes_if_needed(self, chromium_commitish, import_commitish): | 151 def commit_changes_if_needed(self, chromium_commitish, import_commitish): |
| 136 if self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_failure=False)[0
]: | 152 if self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_failure=False)[0
]: |
| 137 self.print_('## commiting changes') | 153 self.print_('## commiting changes') |
| 138 commit_msg = ('Import %s\n' | 154 commit_msg = ('Import %s\n' |
| 139 '\n' | 155 '\n' |
| 140 'Using update-w3c-deps in Chromium %s.\n' | 156 'Using update-w3c-deps in Chromium %s.\n' |
| 141 % (import_commitish, chromium_commitish)) | 157 % (import_commitish, chromium_commitish)) |
| 142 path_to_commit_msg = self.path_from_webkit_base('commit_msg') | 158 path_to_commit_msg = self.path_from_webkit_base('commit_msg') |
| 143 if self.verbose: | 159 if self.verbose: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 dest = self.path_from_webkit_base(*comps) | 215 dest = self.path_from_webkit_base(*comps) |
| 200 if self.verbose: | 216 if self.verbose: |
| 201 self.print_('rm -fr %s' % dest) | 217 self.print_('rm -fr %s' % dest) |
| 202 self.fs.rmtree(dest) | 218 self.fs.rmtree(dest) |
| 203 | 219 |
| 204 def path_from_webkit_base(self, *comps): | 220 def path_from_webkit_base(self, *comps): |
| 205 return self.finder.path_from_webkit_base(*comps) | 221 return self.finder.path_from_webkit_base(*comps) |
| 206 | 222 |
| 207 def print_(self, msg): | 223 def print_(self, msg): |
| 208 self.host.print_(msg) | 224 self.host.print_(msg) |
| OLD | NEW |