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 logging | 19 import logging |
20 | 20 |
21 from webkitpy.common.net.git_cl import GitCL | 21 from webkitpy.common.net.git_cl import GitCL |
22 from webkitpy.common.webkit_finder import WebKitFinder | 22 from webkitpy.common.webkit_finder import WebKitFinder |
23 from webkitpy.common.net.buildbot import current_build_link | 23 from webkitpy.common.net.buildbot import current_build_link |
24 from webkitpy.layout_tests.models.test_expectations import TestExpectations, Tes
tExpectationParser | 24 from webkitpy.layout_tests.models.test_expectations import TestExpectations, Tes
tExpectationParser |
| 25 from webkitpy.layout_tests.port.base import Port |
25 from webkitpy.w3c.common import WPT_REPO_URL, CSS_REPO_URL, WPT_DEST_NAME, CSS_D
EST_NAME, exportable_commits_since | 26 from webkitpy.w3c.common import WPT_REPO_URL, CSS_REPO_URL, WPT_DEST_NAME, CSS_D
EST_NAME, exportable_commits_since |
26 from webkitpy.w3c.directory_owners_extractor import DirectoryOwnersExtractor | 27 from webkitpy.w3c.directory_owners_extractor import DirectoryOwnersExtractor |
27 from webkitpy.w3c.local_wpt import LocalWPT | 28 from webkitpy.w3c.local_wpt import LocalWPT |
28 from webkitpy.w3c.test_copier import TestCopier | 29 from webkitpy.w3c.test_copier import TestCopier |
29 from webkitpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater | 30 from webkitpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater |
30 from webkitpy.w3c.wpt_manifest import WPTManifest | 31 from webkitpy.w3c.wpt_manifest import WPTManifest |
31 | 32 |
32 # Settings for how often to check try job results and how long to wait. | 33 # Settings for how often to check try job results and how long to wait. |
33 POLL_DELAY_SECONDS = 2 * 60 | 34 POLL_DELAY_SECONDS = 2 * 60 |
34 TIMEOUT_SECONDS = 180 * 60 | 35 TIMEOUT_SECONDS = 180 * 60 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 files_to_delete = self.fs.files_under(dest_path, file_filter=is_not_base
line_filter) | 239 files_to_delete = self.fs.files_under(dest_path, file_filter=is_not_base
line_filter) |
239 for subpath in files_to_delete: | 240 for subpath in files_to_delete: |
240 self.remove('LayoutTests', 'external', subpath) | 241 self.remove('LayoutTests', 'external', subpath) |
241 | 242 |
242 _log.info('Importing the tests.') | 243 _log.info('Importing the tests.') |
243 test_copier = TestCopier(self.host, temp_repo_path) | 244 test_copier = TestCopier(self.host, temp_repo_path) |
244 test_copier.do_import() | 245 test_copier.do_import() |
245 | 246 |
246 self.run(['git', 'add', '--all', 'LayoutTests/external/%s' % dest_dir_na
me]) | 247 self.run(['git', 'add', '--all', 'LayoutTests/external/%s' % dest_dir_na
me]) |
247 | 248 |
248 _log.info('Deleting any orphaned baselines.') | 249 self._delete_orphaned_baselines(dest_path) |
249 | |
250 is_baseline_filter = lambda fs, dirname, basename: self.is_baseline(base
name) | |
251 previous_baselines = self.fs.files_under(dest_path, file_filter=is_basel
ine_filter) | |
252 | |
253 for subpath in previous_baselines: | |
254 full_path = self.fs.join(dest_path, subpath) | |
255 if self.fs.glob(full_path.replace('-expected.txt', '*')) == [full_pa
th]: | |
256 self.fs.remove(full_path) | |
257 | 250 |
258 self._generate_manifest(dest_path) | 251 self._generate_manifest(dest_path) |
259 | 252 |
260 _log.info('Updating TestExpectations for any removed or renamed tests.') | 253 _log.info('Updating TestExpectations for any removed or renamed tests.') |
261 self.update_all_test_expectations_files(self._list_deleted_tests(), self
._list_renamed_tests()) | 254 self.update_all_test_expectations_files(self._list_deleted_tests(), self
._list_renamed_tests()) |
262 | 255 |
263 return '%s@%s' % (dest_dir_name, master_commitish) | 256 return '%s@%s' % (dest_dir_name, master_commitish) |
264 | 257 |
265 def _commit_changes(self, commit_message): | 258 def _commit_changes(self, commit_message): |
266 _log.info('Committing changes.') | 259 _log.info('Committing changes.') |
267 self.run(['git', 'commit', '--all', '-F', '-'], stdin=commit_message) | 260 self.run(['git', 'commit', '--all', '-F', '-'], stdin=commit_message) |
268 | 261 |
269 def _has_changes(self): | 262 def _has_changes(self): |
270 return_code, _ = self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_fa
ilure=False) | 263 return_code, _ = self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_fa
ilure=False) |
271 return return_code == 1 | 264 return return_code == 1 |
272 | 265 |
273 def _commit_message(self, chromium_commit, import_commit): | 266 def _commit_message(self, chromium_commit, import_commit): |
274 return ('Import %s\n\n' | 267 return ('Import %s\n\n' |
275 'Using wpt-import in Chromium %s.\n\n' | 268 'Using wpt-import in Chromium %s.\n\n' |
276 'NOEXPORT=true' % | 269 'NOEXPORT=true' % |
277 (import_commit, chromium_commit)) | 270 (import_commit, chromium_commit)) |
278 | 271 |
| 272 def _delete_orphaned_baselines(self, dest_path): |
| 273 _log.info('Deleting any orphaned baselines.') |
| 274 is_baseline_filter = lambda fs, dirname, basename: self.is_baseline(base
name) |
| 275 previous_baselines = self.fs.files_under(dest_path, file_filter=is_basel
ine_filter) |
| 276 for sub_path in previous_baselines: |
| 277 full_baseline_path = self.fs.join(dest_path, sub_path) |
| 278 if not self._has_corresponding_test(full_baseline_path): |
| 279 self.fs.remove(full_baseline_path) |
| 280 |
| 281 def _has_corresponding_test(self, full_baseline_path): |
| 282 base = full_baseline_path.replace('-expected.txt', '') |
| 283 return any(self.fs.exists(base + ext) for ext in Port.supported_file_ext
ensions) |
| 284 |
279 @staticmethod | 285 @staticmethod |
280 def is_baseline(basename): | 286 def is_baseline(basename): |
281 # TODO(qyearsley): Find a better, centralized place for this. | 287 # TODO(qyearsley): Find a better, centralized place for this. |
| 288 # Also, the name for this method should be is_text_baseline. |
282 return basename.endswith('-expected.txt') | 289 return basename.endswith('-expected.txt') |
283 | 290 |
284 def run(self, cmd, exit_on_failure=True, cwd=None, stdin=''): | 291 def run(self, cmd, exit_on_failure=True, cwd=None, stdin=''): |
285 _log.debug('Running command: %s', ' '.join(cmd)) | 292 _log.debug('Running command: %s', ' '.join(cmd)) |
286 | 293 |
287 cwd = cwd or self.finder.webkit_base() | 294 cwd = cwd or self.finder.webkit_base() |
288 proc = self.executive.popen(cmd, stdout=self.executive.PIPE, stderr=self
.executive.PIPE, stdin=self.executive.PIPE, cwd=cwd) | 295 proc = self.executive.popen(cmd, stdout=self.executive.PIPE, stderr=self
.executive.PIPE, stdin=self.executive.PIPE, cwd=cwd) |
289 out, err = proc.communicate(stdin) | 296 out, err = proc.communicate(stdin) |
290 if proc.returncode or self.verbose: | 297 if proc.returncode or self.verbose: |
291 _log.info('# ret> %d', proc.returncode) | 298 _log.info('# ret> %d', proc.returncode) |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 """Returns a dict mapping source to dest name for layout tests that have
been renamed.""" | 486 """Returns a dict mapping source to dest name for layout tests that have
been renamed.""" |
480 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff-
filter=R', '--name-status']) | 487 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff-
filter=R', '--name-status']) |
481 renamed_tests = {} | 488 renamed_tests = {} |
482 for line in out.splitlines(): | 489 for line in out.splitlines(): |
483 _, source_path, dest_path = line.split() | 490 _, source_path, dest_path = line.split() |
484 source_test = self.finder.layout_test_name(source_path) | 491 source_test = self.finder.layout_test_name(source_path) |
485 dest_test = self.finder.layout_test_name(dest_path) | 492 dest_test = self.finder.layout_test_name(dest_path) |
486 if source_test and dest_test: | 493 if source_test and dest_test: |
487 renamed_tests[source_test] = dest_test | 494 renamed_tests[source_test] = dest_test |
488 return renamed_tests | 495 return renamed_tests |
OLD | NEW |