| 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 attempt to | 7 If this script is given the argument --auto-update, it will also attempt to |
| 8 upload a CL, triggery try jobs, and make any changes that are required for | 8 upload a CL, triggery try jobs, and make any changes that are required for |
| 9 new failing tests before committing. | 9 new failing tests before committing. |
| 10 """ | 10 """ |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 for subpath in files_to_delete: | 186 for subpath in files_to_delete: |
| 187 self.remove('LayoutTests', 'imported', subpath) | 187 self.remove('LayoutTests', 'imported', subpath) |
| 188 | 188 |
| 189 self.print_('## Importing the tests.') | 189 self.print_('## Importing the tests.') |
| 190 src_repo = self.path_from_webkit_base(dest_dir_name) | 190 src_repo = self.path_from_webkit_base(dest_dir_name) |
| 191 import_path = self.path_from_webkit_base('Tools', 'Scripts', 'import-w3c
-tests') | 191 import_path = self.path_from_webkit_base('Tools', 'Scripts', 'import-w3c
-tests') |
| 192 self.run([self.host.executable, import_path, '-d', 'imported', src_repo]
) | 192 self.run([self.host.executable, import_path, '-d', 'imported', src_repo]
) |
| 193 | 193 |
| 194 self.run(['git', 'add', '--all', 'LayoutTests/imported/%s' % dest_dir_na
me]) | 194 self.run(['git', 'add', '--all', 'LayoutTests/imported/%s' % dest_dir_na
me]) |
| 195 | 195 |
| 196 self.print_('## Deleting manual tests.') | |
| 197 files_to_delete = self.fs.files_under(dest_path, file_filter=self.is_man
ual_test) | |
| 198 for subpath in files_to_delete: | |
| 199 self.remove('LayoutTests', 'imported', subpath) | |
| 200 | |
| 201 self.print_('## Deleting any orphaned baselines.') | 196 self.print_('## Deleting any orphaned baselines.') |
| 202 previous_baselines = self.fs.files_under(dest_path, file_filter=self.is_
baseline) | 197 previous_baselines = self.fs.files_under(dest_path, file_filter=self.is_
baseline) |
| 203 for subpath in previous_baselines: | 198 for subpath in previous_baselines: |
| 204 full_path = self.fs.join(dest_path, subpath) | 199 full_path = self.fs.join(dest_path, subpath) |
| 205 if self.fs.glob(full_path.replace('-expected.txt', '*')) == [full_pa
th]: | 200 if self.fs.glob(full_path.replace('-expected.txt', '*')) == [full_pa
th]: |
| 206 self.fs.remove(full_path) | 201 self.fs.remove(full_path) |
| 207 | 202 |
| 208 self._generate_manifest(temp_repo_path, dest_path) | 203 self._generate_manifest(temp_repo_path, dest_path) |
| 209 if not keep_w3c_repos_around: | 204 if not keep_w3c_repos_around: |
| 210 self.print_('## Deleting temp repo directory %s.' % temp_repo_path) | 205 self.print_('## Deleting temp repo directory %s.' % temp_repo_path) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 229 self.print_('EOF') | 224 self.print_('EOF') |
| 230 self.fs.write_text_file(path_to_commit_msg, commit_msg) | 225 self.fs.write_text_file(path_to_commit_msg, commit_msg) |
| 231 self.run(['git', 'commit', '-a', '-F', path_to_commit_msg]) | 226 self.run(['git', 'commit', '-a', '-F', path_to_commit_msg]) |
| 232 self.remove(path_to_commit_msg) | 227 self.remove(path_to_commit_msg) |
| 233 self.print_('## Done: changes imported and committed.') | 228 self.print_('## Done: changes imported and committed.') |
| 234 return True | 229 return True |
| 235 else: | 230 else: |
| 236 self.print_('## Done: no changes to import.') | 231 self.print_('## Done: no changes to import.') |
| 237 return False | 232 return False |
| 238 | 233 |
| 239 def is_manual_test(self, fs, dirname, basename): | |
| 240 """Returns True if the file should be removed because it's a manual test
. | |
| 241 | |
| 242 Tests with "-manual" in the name are not considered manual tests | |
| 243 if there is a corresponding JS automation file. | |
| 244 """ | |
| 245 basename_without_extension, _ = self.fs.splitext(basename) | |
| 246 if not basename_without_extension.endswith('-manual'): | |
| 247 return False | |
| 248 dir_from_wpt = fs.relpath(dirname, self.path_from_webkit_base('LayoutTes
ts', 'imported', 'wpt')) | |
| 249 automation_dir = self.path_from_webkit_base('LayoutTests', 'imported', '
wpt_automation', dir_from_wpt) | |
| 250 if fs.isfile(fs.join(automation_dir, '%s-automation.js' % basename_witho
ut_extension)): | |
| 251 return False | |
| 252 return True | |
| 253 | |
| 254 # Callback for FileSystem.files_under; not all arguments used - pylint: disa
ble=unused-argument | 234 # Callback for FileSystem.files_under; not all arguments used - pylint: disa
ble=unused-argument |
| 255 def is_baseline(self, fs, dirname, basename): | 235 def is_baseline(self, fs, dirname, basename): |
| 256 return basename.endswith('-expected.txt') | 236 return basename.endswith('-expected.txt') |
| 257 | 237 |
| 258 def is_not_baseline(self, fs, dirname, basename): | 238 def is_not_baseline(self, fs, dirname, basename): |
| 259 return not self.is_baseline(fs, dirname, basename) | 239 return not self.is_baseline(fs, dirname, basename) |
| 260 | 240 |
| 261 def run(self, cmd, exit_on_failure=True, cwd=None): | 241 def run(self, cmd, exit_on_failure=True, cwd=None): |
| 262 if self.verbose: | 242 if self.verbose: |
| 263 self.print_(' '.join(cmd)) | 243 self.print_(' '.join(cmd)) |
| (...skipping 187 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.""" | 431 """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']) | 432 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff-
filter=R', '--name-status']) |
| 453 renamed_tests = {} | 433 renamed_tests = {} |
| 454 for line in out.splitlines(): | 434 for line in out.splitlines(): |
| 455 _, source_path, dest_path = line.split() | 435 _, source_path, dest_path = line.split() |
| 456 source_test = self.finder.layout_test_name(source_path) | 436 source_test = self.finder.layout_test_name(source_path) |
| 457 dest_test = self.finder.layout_test_name(dest_path) | 437 dest_test = self.finder.layout_test_name(dest_path) |
| 458 if source_test and dest_test: | 438 if source_test and dest_test: |
| 459 renamed_tests[source_test] = dest_test | 439 renamed_tests[source_test] = dest_test |
| 460 return renamed_tests | 440 return renamed_tests |
| OLD | NEW |