| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 log_level = logging.DEBUG if self.verbose else logging.INFO | 45 log_level = logging.DEBUG if self.verbose else logging.INFO |
| 46 logging.basicConfig(level=log_level, format='%(message)s') | 46 logging.basicConfig(level=log_level, format='%(message)s') |
| 47 | 47 |
| 48 if not self.checkout_is_okay(options.allow_local_commits): | 48 if not self.checkout_is_okay(options.allow_local_commits): |
| 49 return 1 | 49 return 1 |
| 50 | 50 |
| 51 self.git_cl = GitCL(self.host, auth_refresh_token_json=options.auth_refr
esh_token_json) | 51 self.git_cl = GitCL(self.host, auth_refresh_token_json=options.auth_refr
esh_token_json) |
| 52 | 52 |
| 53 _log.info('Noting the current Chromium commit.') | 53 _log.info('Noting the current Chromium commit.') |
| 54 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) | 54 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) |
| 55 chromium_commitish = show_ref_output.split()[0] | 55 chromium_commit = show_ref_output.split()[0] |
| 56 | 56 |
| 57 if options.target == 'wpt': | 57 if options.target == 'wpt': |
| 58 import_commitish = self.update(WPT_DEST_NAME, WPT_REPO_URL, options.
keep_w3c_repos_around, options.revision) | 58 import_commit = self.update(WPT_DEST_NAME, WPT_REPO_URL, options.kee
p_w3c_repos_around, options.revision) |
| 59 self._copy_resources() | 59 self._copy_resources() |
| 60 elif options.target == 'css': | 60 elif options.target == 'css': |
| 61 import_commitish = self.update(CSS_DEST_NAME, CSS_REPO_URL, options.
keep_w3c_repos_around, options.revision) | 61 import_commit = self.update(CSS_DEST_NAME, CSS_REPO_URL, options.kee
p_w3c_repos_around, options.revision) |
| 62 else: | 62 else: |
| 63 raise AssertionError("Unsupported target %s" % options.target) | 63 raise AssertionError("Unsupported target %s" % options.target) |
| 64 | 64 |
| 65 has_changes = self.commit_changes_if_needed(chromium_commitish, import_c
ommitish) | 65 has_changes = self._has_changes() |
| 66 if options.auto_update and has_changes: | 66 if not has_changes: |
| 67 _log.info('Done: no changes to import.') |
| 68 return 0 |
| 69 |
| 70 commit_message = self._commit_message(chromium_commit, import_commit) |
| 71 self._commit_changes(commit_message) |
| 72 _log.info('Done: changes imported and committed.') |
| 73 |
| 74 if options.auto_update: |
| 67 commit_successful = self.do_auto_update() | 75 commit_successful = self.do_auto_update() |
| 68 if not commit_successful: | 76 if not commit_successful: |
| 69 return 1 | 77 return 1 |
| 70 return 0 | 78 return 0 |
| 71 | 79 |
| 72 def parse_args(self, argv): | 80 def parse_args(self, argv): |
| 73 parser = argparse.ArgumentParser() | 81 parser = argparse.ArgumentParser() |
| 74 parser.description = __doc__ | 82 parser.description = __doc__ |
| 75 parser.add_argument('-v', '--verbose', action='store_true', | 83 parser.add_argument('-v', '--verbose', action='store_true', |
| 76 help='log what we are doing') | 84 help='log what we are doing') |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 226 |
| 219 if not keep_w3c_repos_around: | 227 if not keep_w3c_repos_around: |
| 220 _log.info('Deleting temp repo directory %s.', temp_repo_path) | 228 _log.info('Deleting temp repo directory %s.', temp_repo_path) |
| 221 self.rmtree(temp_repo_path) | 229 self.rmtree(temp_repo_path) |
| 222 | 230 |
| 223 _log.info('Updating TestExpectations for any removed or renamed tests.') | 231 _log.info('Updating TestExpectations for any removed or renamed tests.') |
| 224 self.update_all_test_expectations_files(self._list_deleted_tests(), self
._list_renamed_tests()) | 232 self.update_all_test_expectations_files(self._list_deleted_tests(), self
._list_renamed_tests()) |
| 225 | 233 |
| 226 return '%s@%s' % (dest_dir_name, master_commitish) | 234 return '%s@%s' % (dest_dir_name, master_commitish) |
| 227 | 235 |
| 228 def commit_changes_if_needed(self, chromium_commitish, import_commitish): | 236 def _commit_changes(self, commit_message): |
| 229 if self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_failure=False)[0
]: | 237 _log.info('Committing changes.') |
| 230 _log.info('Committing changes.') | 238 self.run(['git', 'commit', '--all', '-F', '-'], stdin=commit_message) |
| 231 commit_msg = ('Import %s\n' | 239 |
| 232 '\n' | 240 def _has_changes(self): |
| 233 'Using update-w3c-deps in Chromium %s.\n' | 241 return_code, _ = self.run(['git', 'diff', '--quiet', 'HEAD'], exit_on_fa
ilure=False) |
| 234 % (import_commitish, chromium_commitish)) | 242 return return_code == 1 |
| 235 path_to_commit_msg = self.path_from_webkit_base('commit_msg') | 243 |
| 236 _log.debug('cat > %s <<EOF', path_to_commit_msg) | 244 def _commit_message(self, chromium_commit, import_commit): |
| 237 _log.debug(commit_msg) | 245 return ('Import %s\n\nUsing update-w3c-deps in Chromium %s.\n\n' % |
| 238 _log.debug('EOF') | 246 (import_commit, chromium_commit)) |
| 239 self.fs.write_text_file(path_to_commit_msg, commit_msg) | |
| 240 self.run(['git', 'commit', '-a', '-F', path_to_commit_msg]) | |
| 241 self.remove(path_to_commit_msg) | |
| 242 _log.info('Done: changes imported and committed.') | |
| 243 return True | |
| 244 else: | |
| 245 _log.info('Done: no changes to import.') | |
| 246 return False | |
| 247 | 247 |
| 248 @staticmethod | 248 @staticmethod |
| 249 def is_baseline(basename): | 249 def is_baseline(basename): |
| 250 return basename.endswith('-expected.txt') | 250 return basename.endswith('-expected.txt') |
| 251 | 251 |
| 252 def run(self, cmd, exit_on_failure=True, cwd=None): | 252 def run(self, cmd, exit_on_failure=True, cwd=None, stdin=''): |
| 253 _log.debug('Running command: %s', ' '.join(cmd)) | 253 _log.debug('Running command: %s', ' '.join(cmd)) |
| 254 | 254 |
| 255 cwd = cwd or self.finder.webkit_base() | 255 cwd = cwd or self.finder.webkit_base() |
| 256 proc = self.executive.popen(cmd, stdout=self.executive.PIPE, stderr=self
.executive.PIPE, cwd=cwd) | 256 proc = self.executive.popen(cmd, stdout=self.executive.PIPE, stderr=self
.executive.PIPE, stdin=self.executive.PIPE) |
| 257 out, err = proc.communicate() | 257 out, err = proc.communicate(stdin) |
| 258 if proc.returncode or self.verbose: | 258 if proc.returncode or self.verbose: |
| 259 _log.info('# ret> %d', proc.returncode) | 259 _log.info('# ret> %d', proc.returncode) |
| 260 if out: | 260 if out: |
| 261 for line in out.splitlines(): | 261 for line in out.splitlines(): |
| 262 _log.info('# out> %s', line) | 262 _log.info('# out> %s', line) |
| 263 if err: | 263 if err: |
| 264 for line in err.splitlines(): | 264 for line in err.splitlines(): |
| 265 _log.info('# err> %s', line) | 265 _log.info('# err> %s', line) |
| 266 if exit_on_failure and proc.returncode: | 266 if exit_on_failure and proc.returncode: |
| 267 self.host.exit(proc.returncode) | 267 self.host.exit(proc.returncode) |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 """Returns a dict mapping source to dest name for layout tests that have
been renamed.""" | 452 """Returns a dict mapping source to dest name for layout tests that have
been renamed.""" |
| 453 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff-
filter=R', '--name-status']) | 453 out = self.check_run(['git', 'diff', 'origin/master', '-M100%', '--diff-
filter=R', '--name-status']) |
| 454 renamed_tests = {} | 454 renamed_tests = {} |
| 455 for line in out.splitlines(): | 455 for line in out.splitlines(): |
| 456 _, source_path, dest_path = line.split() | 456 _, source_path, dest_path = line.split() |
| 457 source_test = self.finder.layout_test_name(source_path) | 457 source_test = self.finder.layout_test_name(source_path) |
| 458 dest_test = self.finder.layout_test_name(dest_path) | 458 dest_test = self.finder.layout_test_name(dest_path) |
| 459 if source_test and dest_test: | 459 if source_test and dest_test: |
| 460 renamed_tests[source_test] = dest_test | 460 renamed_tests[source_test] = dest_test |
| 461 return renamed_tests | 461 return renamed_tests |
| OLD | NEW |