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

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

Issue 2665503003: W3C test importer: Clean up temp repo after abort. (Closed)
Patch Set: Rebased Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 _log.info('Local path: %s', temp_repo_path) 75 _log.info('Local path: %s', temp_repo_path)
76 self.run(['git', 'clone', repo_url, temp_repo_path]) 76 self.run(['git', 'clone', repo_url, temp_repo_path])
77 77
78 if options.target == 'wpt': 78 if options.target == 'wpt':
79 commits = self.exportable_but_not_exported_commits(temp_repo_path) 79 commits = self.exportable_but_not_exported_commits(temp_repo_path)
80 if commits: 80 if commits:
81 _log.error('There were exportable but not-yet-exported commits:' ) 81 _log.error('There were exportable but not-yet-exported commits:' )
82 for commit in commits: 82 for commit in commits:
83 _log.error(' https://chromium.googlesource.com/chromium/src /+/%s', commit.sha) 83 _log.error(' https://chromium.googlesource.com/chromium/src /+/%s', commit.sha)
84 _log.error('Aborting import to prevent clobbering these commits. ') 84 _log.error('Aborting import to prevent clobbering these commits. ')
85 if not options.keep_w3c_repos_around:
86 self.clean_up_temp_repo(temp_repo_path)
85 return 1 87 return 1
86 88
87 import_commit = self.update(dest_dir_name, temp_repo_path, options.keep_ w3c_repos_around, options.revision) 89 import_commit = self.update(dest_dir_name, temp_repo_path, options.keep_ w3c_repos_around, options.revision)
88 90
91 if not options.keep_w3c_repos_around:
92 self.clean_up_temp_repo(temp_repo_path)
93
89 if options.target == 'wpt': 94 if options.target == 'wpt':
90 self._copy_resources() 95 self._copy_resources()
91 96
92 has_changes = self._has_changes() 97 has_changes = self._has_changes()
93 if not has_changes: 98 if not has_changes:
94 _log.info('Done: no changes to import.') 99 _log.info('Done: no changes to import.')
95 return 0 100 return 0
96 101
97 commit_message = self._commit_message(chromium_commit, import_commit) 102 commit_message = self._commit_message(chromium_commit, import_commit)
98 self._commit_changes(commit_message) 103 self._commit_changes(commit_message)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 157
153 Returns: 158 Returns:
154 A list of commits in the Chromium repo that are exportable 159 A list of commits in the Chromium repo that are exportable
155 but not yet exported to the web-platform-tests repo. 160 but not yet exported to the web-platform-tests repo.
156 """ 161 """
157 local_wpt = LocalWPT(self.host, path=wpt_path) 162 local_wpt = LocalWPT(self.host, path=wpt_path)
158 assert self.host.filesystem.exists(wpt_path) 163 assert self.host.filesystem.exists(wpt_path)
159 _, chromium_commit = local_wpt.most_recent_chromium_commit() 164 _, chromium_commit = local_wpt.most_recent_chromium_commit()
160 return exportable_commits_since(chromium_commit.sha, self.host, local_wp t) 165 return exportable_commits_since(chromium_commit.sha, self.host, local_wp t)
161 166
167 def clean_up_temp_repo(self, temp_repo_path):
168 _log.info('Deleting temp repo directory %s.', temp_repo_path)
169 self.rmtree(temp_repo_path)
170
162 def _copy_resources(self): 171 def _copy_resources(self):
163 """Copies resources from wpt to LayoutTests/resources. 172 """Copies resources from wpt to LayoutTests/resources.
164 173
165 We copy idlharness.js and testharness.js in wpt to LayoutTests/resources 174 We copy idlharness.js and testharness.js in wpt to LayoutTests/resources
166 in order to use them in non-imported tests. 175 in order to use them in non-imported tests.
167 176
168 If this method is changed, the lists of files expected to be identical 177 If this method is changed, the lists of files expected to be identical
169 in LayoutTests/PRESUBMIT.py should also be changed. 178 in LayoutTests/PRESUBMIT.py should also be changed.
170 """ 179 """
171 resources_to_copy_from_wpt = [ 180 resources_to_copy_from_wpt = [
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 is_baseline_filter = lambda fs, dirname, basename: self.is_baseline(base name) 244 is_baseline_filter = lambda fs, dirname, basename: self.is_baseline(base name)
236 previous_baselines = self.fs.files_under(dest_path, file_filter=is_basel ine_filter) 245 previous_baselines = self.fs.files_under(dest_path, file_filter=is_basel ine_filter)
237 246
238 for subpath in previous_baselines: 247 for subpath in previous_baselines:
239 full_path = self.fs.join(dest_path, subpath) 248 full_path = self.fs.join(dest_path, subpath)
240 if self.fs.glob(full_path.replace('-expected.txt', '*')) == [full_pa th]: 249 if self.fs.glob(full_path.replace('-expected.txt', '*')) == [full_pa th]:
241 self.fs.remove(full_path) 250 self.fs.remove(full_path)
242 251
243 self._generate_manifest(dest_path) 252 self._generate_manifest(dest_path)
244 253
245 if not keep_w3c_repos_around:
246 _log.info('Deleting temp repo directory %s.', temp_repo_path)
247 self.rmtree(temp_repo_path)
248
249 _log.info('Updating TestExpectations for any removed or renamed tests.') 254 _log.info('Updating TestExpectations for any removed or renamed tests.')
250 self.update_all_test_expectations_files(self._list_deleted_tests(), self ._list_renamed_tests()) 255 self.update_all_test_expectations_files(self._list_deleted_tests(), self ._list_renamed_tests())
251 256
252 return '%s@%s' % (dest_dir_name, master_commitish) 257 return '%s@%s' % (dest_dir_name, master_commitish)
253 258
254 def _commit_changes(self, commit_message): 259 def _commit_changes(self, commit_message):
255 _log.info('Committing changes.') 260 _log.info('Committing changes.')
256 self.run(['git', 'commit', '--all', '-F', '-'], stdin=commit_message) 261 self.run(['git', 'commit', '--all', '-F', '-'], stdin=commit_message)
257 262
258 def _has_changes(self): 263 def _has_changes(self):
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 """Returns a dict mapping source to dest name for layout tests that have been renamed.""" 445 """Returns a dict mapping source to dest name for layout tests that have been renamed."""
441 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff- filter=R', '--name-status']) 446 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff- filter=R', '--name-status'])
442 renamed_tests = {} 447 renamed_tests = {}
443 for line in out.splitlines(): 448 for line in out.splitlines():
444 _, source_path, dest_path = line.split() 449 _, source_path, dest_path = line.split()
445 source_test = self.finder.layout_test_name(source_path) 450 source_test = self.finder.layout_test_name(source_path)
446 dest_test = self.finder.layout_test_name(dest_path) 451 dest_test = self.finder.layout_test_name(dest_path)
447 if source_test and dest_test: 452 if source_test and dest_test:
448 renamed_tests[source_test] = dest_test 453 renamed_tests[source_test] = dest_test
449 return renamed_tests 454 return renamed_tests
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698