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

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

Issue 2247923002: Refactoring: Extract a method _copy_resources_to_wpt in deps_updater.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reword Created 4 years, 4 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 | no next file » | 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 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
45 45
46 if not self.checkout_is_okay(): 46 if not self.checkout_is_okay():
47 return 1 47 return 1
48 48
49 self.print_('## Noting the current Chromium commit.') 49 self.print_('## Noting the current Chromium commit.')
50 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD']) 50 _, show_ref_output = self.run(['git', 'show-ref', 'HEAD'])
51 chromium_commitish = show_ref_output.split()[0] 51 chromium_commitish = show_ref_output.split()[0]
52 52
53 if self.target == 'wpt': 53 if self.target == 'wpt':
54 import_commitish = self.update(WPT_DEST_NAME, WPT_REPO_URL) 54 import_commitish = self.update(WPT_DEST_NAME, WPT_REPO_URL)
55 55 self._copy_resources_to_wpt()
56 for resource in ['testharnessreport.js', 'WebIDLParser.js']:
57 source = self.path_from_webkit_base('LayoutTests', 'resources', resource)
58 destination = self.path_from_webkit_base('LayoutTests', 'importe d', WPT_DEST_NAME, 'resources', resource)
59 self.copyfile(source, destination)
60 self.run(['git', 'add', destination])
61
62 for resource in ['vendor-prefix.js']:
63 source = self.path_from_webkit_base('LayoutTests', 'resources', resource)
64 destination = self.path_from_webkit_base('LayoutTests', 'importe d', WPT_DEST_NAME, 'common', resource)
65 self.copyfile(source, destination)
66 self.run(['git', 'add', destination])
67
68 elif self.target == 'css': 56 elif self.target == 'css':
69 import_commitish = self.update(CSS_DEST_NAME, WPT_REPO_URL) 57 import_commitish = self.update(CSS_DEST_NAME, WPT_REPO_URL)
70 else: 58 else:
71 raise AssertionError("Unsupported target %s" % self.target) 59 raise AssertionError("Unsupported target %s" % self.target)
72 60
73 has_changes = self.commit_changes_if_needed(chromium_commitish, import_c ommitish) 61 has_changes = self.commit_changes_if_needed(chromium_commitish, import_c ommitish)
74 if self.auto_update and has_changes: 62 if self.auto_update and has_changes:
75 try_bots = self.host.builders.all_try_builder_names() 63 try_bots = self.host.builders.all_try_builder_names()
76 data_file_path = self.finder.path_from_webkit_base('Tools', 'Scripts ', 'webkitpy', 'w3c', 'directory_owners.json') 64 data_file_path = self.finder.path_from_webkit_base('Tools', 'Scripts ', 'webkitpy', 'w3c', 'directory_owners.json')
77 with open(data_file_path) as data_file: 65 with open(data_file_path) as data_file:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if self.fs.exists(self.path_from_webkit_base(WPT_DEST_NAME)): 118 if self.fs.exists(self.path_from_webkit_base(WPT_DEST_NAME)):
131 self.print_('## WebKit/%s exists; aborting.' % WPT_DEST_NAME) 119 self.print_('## WebKit/%s exists; aborting.' % WPT_DEST_NAME)
132 return False 120 return False
133 121
134 if self.fs.exists(self.path_from_webkit_base(CSS_DEST_NAME)): 122 if self.fs.exists(self.path_from_webkit_base(CSS_DEST_NAME)):
135 self.print_('## WebKit/%s repo exists; aborting.' % CSS_DEST_NAME) 123 self.print_('## WebKit/%s repo exists; aborting.' % CSS_DEST_NAME)
136 return False 124 return False
137 125
138 return True 126 return True
139 127
128 def _copy_resources_to_wpt(self):
129 """Copies some files over to a newly-updated wpt directory.
130
131 There are some resource files in our repository that we want to use
Dirk Pranke 2016/08/17 00:02:43 One last nit: s/There are some resource/These are/
132 instead of the upstream versions.
133 """
134 resources_to_copy = [
135 ('testharnessreport.js', 'resources'),
136 ('WebIDLParser.js', 'resources'),
137 ('vendor-prefix.js', 'common'),
138 ]
139 for filename, wpt_subdir in resources_to_copy:
140 source = self.path_from_webkit_base('LayoutTests', 'resources', file name)
141 destination = self.path_from_webkit_base('LayoutTests', 'imported', WPT_DEST_NAME, wpt_subdir, filename)
142 self.copyfile(source, destination)
143 self.run(['git', 'add', destination])
144
140 def update(self, dest_dir_name, url): 145 def update(self, dest_dir_name, url):
141 """Updates an imported repository. 146 """Updates an imported repository.
142 147
143 Args: 148 Args:
144 dest_dir_name: The destination directory name. 149 dest_dir_name: The destination directory name.
145 url: URL of the git repository. 150 url: URL of the git repository.
146 151
147 Returns: 152 Returns:
148 A string for the commit description "<destination>@<commitish>". 153 A string for the commit description "<destination>@<commitish>".
149 """ 154 """
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 def generate_upload_command(self, email_list): 370 def generate_upload_command(self, email_list):
366 message = """W3C auto test importer 371 message = """W3C auto test importer
367 372
368 TBR=qyearsley@chromium.org""" 373 TBR=qyearsley@chromium.org"""
369 374
370 command = ['git', 'cl', 'upload', '-f', '-m', message] 375 command = ['git', 'cl', 'upload', '-f', '-m', message]
371 command += ['--cc=' + email for email in email_list] 376 command += ['--cc=' + email for email in email_list]
372 if self.auth_refresh_token_json: 377 if self.auth_refresh_token_json:
373 command += ['--auth-refresh-token-json', self.auth_refresh_token_jso n] 378 command += ['--auth-refresh-token-json', self.auth_refresh_token_jso n]
374 return command 379 return command
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698