Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py

Issue 2831883002: webkitpy: Reduce usage of path_from_webkit_base(). (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 _log.debug('Noting the current Chromium commit.') 61 _log.debug('Noting the current Chromium commit.')
62 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) 62 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD'])
63 chromium_commit = show_ref_output.split()[0] 63 chromium_commit = show_ref_output.split()[0]
64 64
65 dest_dir_name = WPT_DEST_NAME 65 dest_dir_name = WPT_DEST_NAME
66 repo_url = WPT_REPO_URL 66 repo_url = WPT_REPO_URL
67 67
68 # TODO(qyearsley): Simplify this to use LocalWPT.fetch when csswg-test 68 # TODO(qyearsley): Simplify this to use LocalWPT.fetch when csswg-test
69 # is merged into web-platform-tests (crbug.com/706118). 69 # is merged into web-platform-tests (crbug.com/706118).
70 temp_repo_path = self.path_from_webkit_base(dest_dir_name) 70 temp_repo_path = self.finder.path_from_webkit_base(dest_dir_name)
71 _log.info('Cloning repo: %s', repo_url) 71 _log.info('Cloning repo: %s', repo_url)
72 _log.info('Local path: %s', temp_repo_path) 72 _log.info('Local path: %s', temp_repo_path)
73 self.run(['git', 'clone', repo_url, temp_repo_path]) 73 self.run(['git', 'clone', repo_url, temp_repo_path])
74 74
75 if not options.ignore_exportable_commits: 75 if not options.ignore_exportable_commits:
76 commits = self.exportable_but_not_exported_commits(temp_repo_path) 76 commits = self.exportable_but_not_exported_commits(temp_repo_path)
77 if commits: 77 if commits:
78 # If there are exportable commits, then there's no more work 78 # If there are exportable commits, then there's no more work
79 # to do for now. This isn't really an error case; we expect 79 # to do for now. This isn't really an error case; we expect
80 # to hit this case some of the time. 80 # to hit this case some of the time.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 git_diff_retcode, _ = self.run(['git', 'diff', '--quiet', 'HEAD'], exit_ on_failure=False) 132 git_diff_retcode, _ = self.run(['git', 'diff', '--quiet', 'HEAD'], exit_ on_failure=False)
133 if git_diff_retcode: 133 if git_diff_retcode:
134 _log.warning('Checkout is dirty; aborting.') 134 _log.warning('Checkout is dirty; aborting.')
135 return False 135 return False
136 136
137 local_commits = self.run(['git', 'log', '--oneline', 'origin/master..HEA D'])[1] 137 local_commits = self.run(['git', 'log', '--oneline', 'origin/master..HEA D'])[1]
138 if local_commits and not allow_local_commits: 138 if local_commits and not allow_local_commits:
139 _log.warning('Checkout has local commits; aborting. Use --allow-loca l-commits to allow this.') 139 _log.warning('Checkout has local commits; aborting. Use --allow-loca l-commits to allow this.')
140 return False 140 return False
141 141
142 if self.fs.exists(self.path_from_webkit_base(WPT_DEST_NAME)): 142 if self.fs.exists(self.finder.path_from_webkit_base(WPT_DEST_NAME)):
143 _log.warning('WebKit/%s exists; aborting.', WPT_DEST_NAME) 143 _log.warning('WebKit/%s exists; aborting.', WPT_DEST_NAME)
144 return False 144 return False
145 145
146 return True 146 return True
147 147
148 def exportable_but_not_exported_commits(self, wpt_path): 148 def exportable_but_not_exported_commits(self, wpt_path):
149 """Checks for commits that might be overwritten by importing. 149 """Checks for commits that might be overwritten by importing.
150 150
151 Args: 151 Args:
152 wpt_path: The path to a local checkout of web-platform-tests. 152 wpt_path: The path to a local checkout of web-platform-tests.
(...skipping 18 matching lines...) Expand all
171 in order to use them in non-imported tests. 171 in order to use them in non-imported tests.
172 172
173 If this method is changed, the lists of files expected to be identical 173 If this method is changed, the lists of files expected to be identical
174 in LayoutTests/PRESUBMIT.py should also be changed. 174 in LayoutTests/PRESUBMIT.py should also be changed.
175 """ 175 """
176 resources_to_copy_from_wpt = [ 176 resources_to_copy_from_wpt = [
177 ('idlharness.js', 'resources'), 177 ('idlharness.js', 'resources'),
178 ('testharness.js', 'resources'), 178 ('testharness.js', 'resources'),
179 ] 179 ]
180 for filename, wpt_subdir in resources_to_copy_from_wpt: 180 for filename, wpt_subdir in resources_to_copy_from_wpt:
181 source = self.path_from_webkit_base('LayoutTests', 'external', WPT_D EST_NAME, wpt_subdir, filename) 181 source = self.finder.path_from_layout_tests('external', WPT_DEST_NAM E, wpt_subdir, filename)
182 destination = self.path_from_webkit_base('LayoutTests', 'resources', filename) 182 destination = self.finder.path_from_layout_tests('resources', filena me)
183 self.copyfile(source, destination) 183 self.copyfile(source, destination)
184 self.run(['git', 'add', destination]) 184 self.run(['git', 'add', destination])
185 185
186 def _generate_manifest(self, dest_path): 186 def _generate_manifest(self, dest_path):
187 """Generates MANIFEST.json for imported tests. 187 """Generates MANIFEST.json for imported tests.
188 188
189 Args: 189 Args:
190 dest_path: Path to the destination WPT directory. 190 dest_path: Path to the destination WPT directory.
191 191
192 Runs the (newly-updated) manifest command if it's found, and then 192 Runs the (newly-updated) manifest command if it's found, and then
(...skipping 22 matching lines...) Expand all
215 if revision is not None: 215 if revision is not None:
216 _log.info('Checking out %s', revision) 216 _log.info('Checking out %s', revision)
217 self.run(['git', 'checkout', revision], cwd=temp_repo_path) 217 self.run(['git', 'checkout', revision], cwd=temp_repo_path)
218 218
219 self.run(['git', 'submodule', 'update', '--init', '--recursive'], cwd=te mp_repo_path) 219 self.run(['git', 'submodule', 'update', '--init', '--recursive'], cwd=te mp_repo_path)
220 220
221 _log.info('Noting the revision we are importing.') 221 _log.info('Noting the revision we are importing.')
222 _, show_ref_output = self.run(['git', 'show-ref', 'origin/master'], cwd= temp_repo_path) 222 _, show_ref_output = self.run(['git', 'show-ref', 'origin/master'], cwd= temp_repo_path)
223 master_commitish = show_ref_output.split()[0] 223 master_commitish = show_ref_output.split()[0]
224 224
225 dest_path = self.path_from_webkit_base('LayoutTests', 'external', dest_d ir_name) 225 dest_path = self.finder.path_from_layout_tests('external', dest_dir_name )
226 self._clear_out_dest_path(dest_path) 226 self._clear_out_dest_path(dest_path)
227 227
228 _log.info('Importing the tests.') 228 _log.info('Importing the tests.')
229 test_copier = TestCopier(self.host, temp_repo_path) 229 test_copier = TestCopier(self.host, temp_repo_path)
230 test_copier.do_import() 230 test_copier.do_import()
231 231
232 self.run(['git', 'add', '--all', 'LayoutTests/external/%s' % dest_dir_na me]) 232 self.run(['git', 'add', '--all', 'LayoutTests/external/%s' % dest_dir_na me])
233 233
234 self._delete_orphaned_baselines(dest_path) 234 self._delete_orphaned_baselines(dest_path)
235 235
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 return_code, out = self.run(command) 305 return_code, out = self.run(command)
306 if return_code: 306 if return_code:
307 raise Exception('%s failed with exit code %d.' % ' '.join(command), return_code) 307 raise Exception('%s failed with exit code %d.' % ' '.join(command), return_code)
308 return out 308 return out
309 309
310 def copyfile(self, source, destination): 310 def copyfile(self, source, destination):
311 _log.debug('cp %s %s', source, destination) 311 _log.debug('cp %s %s', source, destination)
312 self.fs.copyfile(source, destination) 312 self.fs.copyfile(source, destination)
313 313
314 def remove(self, *comps): 314 def remove(self, *comps):
315 dest = self.path_from_webkit_base(*comps) 315 dest = self.finder.path_from_webkit_base(*comps)
316 _log.debug('rm %s', dest) 316 _log.debug('rm %s', dest)
317 self.fs.remove(dest) 317 self.fs.remove(dest)
318 318
319 def rmtree(self, *comps): 319 def rmtree(self, *comps):
320 dest = self.path_from_webkit_base(*comps) 320 dest = self.finder.path_from_webkit_base(*comps)
321 _log.debug('rm -fr %s', dest) 321 _log.debug('rm -fr %s', dest)
322 self.fs.rmtree(dest) 322 self.fs.rmtree(dest)
323 323
324 def path_from_webkit_base(self, *comps):
325 return self.finder.path_from_webkit_base(*comps)
326
327 def do_auto_update(self): 324 def do_auto_update(self):
328 """Attempts to upload a CL, make any required adjustments, and commit. 325 """Attempts to upload a CL, make any required adjustments, and commit.
329 326
330 This function assumes that the imported repo has already been updated, 327 This function assumes that the imported repo has already been updated,
331 and that change has been committed. There may be newly-failing tests, 328 and that change has been committed. There may be newly-failing tests,
332 so before being able to commit these new changes, we may need to update 329 so before being able to commit these new changes, we may need to update
333 TestExpectations or download new baselines. 330 TestExpectations or download new baselines.
334 331
335 Returns: 332 Returns:
336 True if successfully committed, False otherwise. 333 True if successfully committed, False otherwise.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 """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."""
483 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'])
484 renamed_tests = {} 481 renamed_tests = {}
485 for line in out.splitlines(): 482 for line in out.splitlines():
486 _, source_path, dest_path = line.split() 483 _, source_path, dest_path = line.split()
487 source_test = self.finder.layout_test_name(source_path) 484 source_test = self.finder.layout_test_name(source_path)
488 dest_test = self.finder.layout_test_name(dest_path) 485 dest_test = self.finder.layout_test_name(dest_path)
489 if source_test and dest_test: 486 if source_test and dest_test:
490 renamed_tests[source_test] = dest_test 487 renamed_tests[source_test] = dest_test
491 return renamed_tests 488 return renamed_tests
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698