blob: a359beb25d55abfe6a7f973cb0df165d51cabf15 [file] [log] [blame]
Blink Reformat4c46d092018-04-07 15:32:371# Copyright (C) 2014 Google Inc. All rights reserved.
2#
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are
5# met:
6#
7# * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above
10# copyright notice, this list of conditions and the following disclaimer
11# in the documentation and/or other materials provided with the
12# distribution.
13# * Neither the name of Google Inc. nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Yang Guo75beda92019-10-28 07:29:2528"""
29DevTools presubmit script
Blink Reformat4c46d092018-04-07 15:32:3730
31See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
32for more details about the presubmit API built into gcl.
33"""
34
35import sys
36
Yang Guoa7845d52019-10-31 10:30:2337EXCLUSIVE_CHANGE_DIRECTORIES = [
38 [ 'third_party', 'v8' ],
39 [ 'node_modules' ],
40 [ 'OWNERS' ],
41]
42
Liviu Raufd2e3212019-12-18 15:38:2043AUTOROLL_ACCOUNT = "devtools-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com"
Mathias Bynensa0a6e292019-12-17 12:24:0844
Yang Guoa7845d52019-10-31 10:30:2345def _CheckChangesAreExclusiveToDirectory(input_api, output_api):
Tim van der Lippebc42a632019-11-28 14:22:5546 if input_api.change.DISABLE_THIRD_PARTY_CHECK != None:
47 return []
Brandon Goddarde7028672020-01-30 17:31:0448 results = [output_api.PresubmitNotifyResult('Directory Exclusivity Check:')]
Yang Guoa7845d52019-10-31 10:30:2349 def IsParentDir(file, dir):
50 while file != '':
51 if file == dir:
52 return True
53 file = input_api.os_path.dirname(file)
Yang Guoa7845d52019-10-31 10:30:2354 return False
55
56 def FileIsInDir(file, dirs):
57 for dir in dirs:
58 if IsParentDir(file, dir):
59 return True
60
61 affected_files = input_api.LocalPaths()
Yang Guoa7845d52019-10-31 10:30:2362 num_affected = len(affected_files)
63 for dirs in EXCLUSIVE_CHANGE_DIRECTORIES:
Paul Lewis14effba2019-12-02 14:56:4064 dir_list = ', '.join(dirs)
Yang Guoa7845d52019-10-31 10:30:2365 affected_in_dir = filter(lambda f: FileIsInDir(f, dirs), affected_files)
66 num_in_dir = len(affected_in_dir)
67 if num_in_dir == 0:
68 continue
Tim van der Lippeebb94a92019-11-19 17:07:5369 # Addition of new third_party folders must have a new entry in `.gitignore`
70 if '.gitignore' in affected_files:
71 num_in_dir = num_in_dir + 1
Yang Guoa7845d52019-10-31 10:30:2372 if num_in_dir < num_affected:
Brandon Goddarde7028672020-01-30 17:31:0473 results.append(output_api
Paul Lewis14effba2019-12-02 14:56:4074 .PresubmitError(('CLs that affect files in "%s" should be limited to these files/directories.' % dir_list) +
Brandon Goddarde7028672020-01-30 17:31:0475 ' You can disable this check by adding DISABLE_THIRD_PARTY_CHECK=<reason> to your commit message'))
76 break
77
78 return results
Yang Guoa7845d52019-10-31 10:30:2379
Blink Reformat4c46d092018-04-07 15:32:3780
81def _CheckBuildGN(input_api, output_api):
Brandon Goddarde7028672020-01-30 17:31:0482 results = [output_api.PresubmitNotifyResult('Running BUILD.GN check:')]
Yang Guo75beda92019-10-28 07:29:2583 script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts', 'check_gn.js')
Brandon Goddarde7028672020-01-30 17:31:0484 results.extend(_checkWithNodeScript(input_api, output_api, script_path))
85 return results
Blink Reformat4c46d092018-04-07 15:32:3786
87
Tim van der Lippee4bdd742019-12-17 15:40:1688def _CheckJSON(input_api, output_api):
Brandon Goddarde7028672020-01-30 17:31:0489 results = [output_api.PresubmitNotifyResult('Running JSON Validator:')]
Tim van der Lippee4bdd742019-12-17 15:40:1690 script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts', 'json_validator', 'validate_module_json.js')
Brandon Goddarde7028672020-01-30 17:31:0491 results.extend(_checkWithNodeScript(input_api, output_api, script_path))
92 return results
Tim van der Lippee4bdd742019-12-17 15:40:1693
94
Brandon Goddard53faba12020-01-24 16:55:0495def _CheckLicenses(input_api, output_api):
Brandon Goddarde7028672020-01-30 17:31:0496 results = [output_api.PresubmitNotifyResult('Running License Header Check:')]
Brandon Goddard53faba12020-01-24 16:55:0497 script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts', 'test', 'run_license_header_check.js')
Brandon Goddarde7028672020-01-30 17:31:0498 results.extend(_checkWithNodeScript(input_api, output_api, script_path))
99 return results
Brandon Goddard53faba12020-01-24 16:55:04100
101
Blink Reformat4c46d092018-04-07 15:32:37102def _CheckFormat(input_api, output_api):
Brandon Goddarde7028672020-01-30 17:31:04103 results = [output_api.PresubmitNotifyResult('Running Format Checks:')]
Blink Reformat4c46d092018-04-07 15:32:37104 def popen(args):
105 return input_api.subprocess.Popen(args=args, stdout=input_api.subprocess.PIPE, stderr=input_api.subprocess.STDOUT)
106
107 affected_files = _getAffectedJSFiles(input_api)
108 if len(affected_files) == 0:
Brandon Goddarde7028672020-01-30 17:31:04109 return results
Blink Reformat4c46d092018-04-07 15:32:37110 original_sys_path = sys.path
111 try:
Yang Guo75beda92019-10-28 07:29:25112 sys.path = sys.path + [input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts')]
Yang Guod8176982019-10-04 20:30:35113 import devtools_paths
Blink Reformat4c46d092018-04-07 15:32:37114 finally:
115 sys.path = original_sys_path
116
117 ignore_files = []
118 eslint_ignore_path = input_api.os_path.join(input_api.PresubmitLocalPath(), '.eslintignore')
119 with open(eslint_ignore_path, 'r') as ignore_manifest:
120 for line in ignore_manifest:
Jack Frankline245d1a2020-02-13 15:25:13121 if '*' not in line.strip():
122 ignore_files.append(input_api.os_path.normpath(line.strip()))
Mathias Bynens032591d2019-10-21 09:51:31123 formattable_files = [
124 affected_file for affected_file in affected_files if all(ignore_file not in affected_file for ignore_file in ignore_files)
125 ]
Blink Reformat4c46d092018-04-07 15:32:37126 if len(formattable_files) == 0:
Brandon Goddarde7028672020-01-30 17:31:04127 return results
Blink Reformat4c46d092018-04-07 15:32:37128
129 check_formatting_process = popen(['git', 'cl', 'format', '--js', '--dry-run'] + formattable_files)
130 check_formatting_process.communicate()
131 if check_formatting_process.returncode == 0:
Brandon Goddarde7028672020-01-30 17:31:04132 return results
Blink Reformat4c46d092018-04-07 15:32:37133
134 format_args = ['git', 'cl', 'format', '--js'] + formattable_files
135 format_process = popen(format_args)
136 format_out, _ = format_process.communicate()
137 if format_process.returncode != 0:
Brandon Goddarde7028672020-01-30 17:31:04138 results.append(output_api.PresubmitError(format_out))
139 return results
Blink Reformat4c46d092018-04-07 15:32:37140
Brandon Goddarde7028672020-01-30 17:31:04141 results.append(output_api.PresubmitError('ERROR: Found formatting violations.\n'
Yang Guo75beda92019-10-28 07:29:25142 'Ran clang-format on diff\n'
Brandon Goddarde7028672020-01-30 17:31:04143 'Use git status to check the formatting changes'))
144 results.append(output_api.PresubmitError(format_out))
145 return results
Blink Reformat4c46d092018-04-07 15:32:37146
147
e52a82bdfb5106bd658c2c5ea465e200594be1e2019-10-29 23:02:46148def _CheckDevtoolsLocalization(input_api, output_api, check_all_files=False): # pylint: disable=invalid-name
Brandon Goddarde7028672020-01-30 17:31:04149 results = [output_api.PresubmitNotifyResult('Running Localization Checks:')]
Mandy Chene997da72019-08-22 23:50:19150 devtools_root = input_api.PresubmitLocalPath()
vidorteg2b675b02019-11-25 17:51:28151 script_path = input_api.os_path.join(devtools_root, 'scripts', 'test', 'run_localization_check.py')
Paul Lewis954a5a92019-11-20 15:33:49152 if check_all_files == True:
vidorteg2b675b02019-11-25 17:51:28153 # Scan all files and fix any errors
vidorteg75c025e2019-11-25 17:52:43154 args = ['--autofix', '--all']
Paul Lewis954a5a92019-11-20 15:33:49155 else:
vidorteg2b675b02019-11-25 17:51:28156 devtools_front_end = input_api.os_path.join(devtools_root, 'front_end')
157 affected_front_end_files = _getAffectedFiles(input_api, [devtools_front_end], ['D'],
158 ['.js', '.grdp', '.grd', 'module.json'])
159
160 if len(affected_front_end_files) == 0:
Brandon Goddarde7028672020-01-30 17:31:04161 return results
Christy Chen1ab87e02020-01-31 00:32:16162
163 with input_api.CreateTemporaryFile() as file_list:
164 for affected_file in affected_front_end_files:
165 file_list.write(affected_file + '\n')
166 file_list.close()
167
vidorteg2b675b02019-11-25 17:51:28168 # Scan only added or modified files with specific extensions.
Christy Chen1ab87e02020-01-31 00:32:16169 args = ['--autofix', '--file-list', file_list.name]
vidorteg2b675b02019-11-25 17:51:28170 process = input_api.subprocess.Popen(
171 [input_api.python_executable, script_path] + args, stdout=input_api.subprocess.PIPE, stderr=input_api.subprocess.STDOUT)
172 out, _ = process.communicate()
173 if process.returncode != 0:
Brandon Goddarde7028672020-01-30 17:31:04174 results.append(output_api.PresubmitError(out))
175 else:
176 results.append(output_api.PresubmitNotifyResult(out))
177 return results
Mandy Chen465b4f72019-03-21 22:52:54178
179
Blink Reformat4c46d092018-04-07 15:32:37180def _CheckDevtoolsStyle(input_api, output_api):
Brandon Goddarde7028672020-01-30 17:31:04181 results = [output_api.PresubmitNotifyResult('Running Devtools Style Check:')]
Yang Guo75beda92019-10-28 07:29:25182 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts', 'test', 'run_lint_check.py')
Tim van der Lippec85c3122019-09-19 11:27:04183 process = input_api.subprocess.Popen([input_api.python_executable, lint_path],
184 stdout=input_api.subprocess.PIPE,
185 stderr=input_api.subprocess.STDOUT)
186 out, _ = process.communicate()
187 if process.returncode != 0:
Brandon Goddarde7028672020-01-30 17:31:04188 results.append(output_api.PresubmitError(out))
189 else:
190 results.append(output_api.PresubmitNotifyResult(out))
191 return results
Blink Reformat4c46d092018-04-07 15:32:37192
193
Joel Einbinderf6f86b62019-06-10 23:19:12194def _CheckOptimizeSVGHashes(input_api, output_api):
Brandon Goddarde7028672020-01-30 17:31:04195 results = [output_api.PresubmitNotifyResult('Running SVG Optimization Check:')]
Blink Reformat4c46d092018-04-07 15:32:37196 if not input_api.platform.startswith('linux'):
Brandon Goddarde7028672020-01-30 17:31:04197 return results
Blink Reformat4c46d092018-04-07 15:32:37198
199 original_sys_path = sys.path
200 try:
201 sys.path = sys.path + [input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts', 'build')]
202 import devtools_file_hashes
203 finally:
204 sys.path = original_sys_path
205
206 absolute_local_paths = [af.AbsoluteLocalPath() for af in input_api.AffectedFiles(include_deletes=False)]
Yang Guo75beda92019-10-28 07:29:25207 images_src_path = input_api.os_path.join('devtools', 'front_end', 'Images', 'src')
208 image_source_file_paths = [path for path in absolute_local_paths if images_src_path in path and path.endswith('.svg')]
209 image_sources_path = input_api.os_path.join(input_api.PresubmitLocalPath(), 'front_end', 'Images', 'src')
210 hashes_file_name = 'optimize_svg.hashes'
Blink Reformat4c46d092018-04-07 15:32:37211 hashes_file_path = input_api.os_path.join(image_sources_path, hashes_file_name)
212 invalid_hash_file_paths = devtools_file_hashes.files_with_invalid_hashes(hashes_file_path, image_source_file_paths)
213 if len(invalid_hash_file_paths) == 0:
Brandon Goddarde7028672020-01-30 17:31:04214 return results
Blink Reformat4c46d092018-04-07 15:32:37215 invalid_hash_file_names = [input_api.os_path.basename(file_path) for file_path in invalid_hash_file_paths]
Yang Guo75beda92019-10-28 07:29:25216 file_paths_str = ', '.join(invalid_hash_file_names)
217 error_message = 'The following SVG files should be optimized using optimize_svg_images script before uploading: \n - %s' % file_paths_str
Brandon Goddarde7028672020-01-30 17:31:04218 results.append(output_api.PresubmitError(error_message))
219 return results
Blink Reformat4c46d092018-04-07 15:32:37220
221
222def _CheckCSSViolations(input_api, output_api):
Brandon Goddarde7028672020-01-30 17:31:04223 results = [output_api.PresubmitNotifyResult('Running CSS Violation Check:')]
Blink Reformat4c46d092018-04-07 15:32:37224 for f in input_api.AffectedFiles(include_deletes=False):
Yang Guo75beda92019-10-28 07:29:25225 if not f.LocalPath().endswith('.css'):
Blink Reformat4c46d092018-04-07 15:32:37226 continue
227 for line_number, line in f.ChangedContents():
Yang Guo75beda92019-10-28 07:29:25228 if '/deep/' in line:
229 results.append(output_api.PresubmitError(('%s:%d uses /deep/ selector') % (f.LocalPath(), line_number)))
230 if '::shadow' in line:
231 results.append(output_api.PresubmitError(('%s:%d uses ::shadow selector') % (f.LocalPath(), line_number)))
Blink Reformat4c46d092018-04-07 15:32:37232 return results
233
Mathias Bynens032591d2019-10-21 09:51:31234
Tim van der Lippe5279f842020-01-14 16:26:38235def _CheckNoUncheckedFiles(input_api, output_api):
236 results = []
237 process = input_api.subprocess.Popen(['git', 'diff', '--exit-code'],
238 stdout=input_api.subprocess.PIPE,
239 stderr=input_api.subprocess.STDOUT)
240 out, _ = process.communicate()
241 if process.returncode != 0:
242 return [output_api.PresubmitError('You have changed files that need to be committed.')]
243 return []
244
Tim van der Lippe8fdda112020-01-27 11:27:06245def _CheckForTooLargeFiles(input_api, output_api):
Christy Chen1ab87e02020-01-31 00:32:16246 """Avoid large files, especially binary files, in the repository since
Tim van der Lippe8fdda112020-01-27 11:27:06247 git doesn't scale well for those. They will be in everyone's repo
248 clones forever, forever making Chromium slower to clone and work
249 with."""
Christy Chen1ab87e02020-01-31 00:32:16250 # Uploading files to cloud storage is not trivial so we don't want
251 # to set the limit too low, but the upper limit for "normal" large
252 # files seems to be 1-2 MB, with a handful around 5-8 MB, so
253 # anything over 20 MB is exceptional.
254 TOO_LARGE_FILE_SIZE_LIMIT = 20 * 1024 * 1024 # 10 MB
255 too_large_files = []
256 for f in input_api.AffectedFiles():
257 # Check both added and modified files (but not deleted files).
258 if f.Action() in ('A', 'M'):
259 size = input_api.os_path.getsize(f.AbsoluteLocalPath())
260 if size > TOO_LARGE_FILE_SIZE_LIMIT:
261 too_large_files.append("%s: %d bytes" % (f.LocalPath(), size))
262 if too_large_files:
263 message = (
264 'Do not commit large files to git since git scales badly for those.\n' +
265 'Instead put the large files in cloud storage and use DEPS to\n' +
266 'fetch them.\n' + '\n'.join(too_large_files)
267 )
268 return [output_api.PresubmitError(
269 'Too large files found in commit', long_text=message + '\n')]
270 else:
271 return []
Tim van der Lippe8fdda112020-01-27 11:27:06272
Tim van der Lippe5279f842020-01-14 16:26:38273
Yang Guo4fd355c2019-09-19 08:59:03274def _CommonChecks(input_api, output_api):
Mathias Bynens032591d2019-10-21 09:51:31275 """Checks common to both upload and commit."""
276 results = []
Liviu Raufd2e3212019-12-18 15:38:20277 results.extend(input_api.canned_checks.CheckAuthorizedAuthor(input_api, output_api,
278 bot_whitelist=[AUTOROLL_ACCOUNT]
279 ))
Mathias Bynens032591d2019-10-21 09:51:31280 results.extend(input_api.canned_checks.CheckOwnersFormat(input_api, output_api))
281 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
282 results.extend(input_api.canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol(input_api, output_api))
283 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(input_api, output_api))
284 results.extend(input_api.canned_checks.CheckGenderNeutral(input_api, output_api))
Blink Reformat4c46d092018-04-07 15:32:37285 results.extend(_CheckBuildGN(input_api, output_api))
Tim van der Lippee4bdd742019-12-17 15:40:16286 results.extend(_CheckJSON(input_api, output_api))
Brandon Goddard53faba12020-01-24 16:55:04287 results.extend(_CheckLicenses(input_api, output_api))
Blink Reformat4c46d092018-04-07 15:32:37288 results.extend(_CheckDevtoolsStyle(input_api, output_api))
Tim van der Lippe5497d482020-01-14 15:27:30289 results.extend(_CheckFormat(input_api, output_api))
Joel Einbinderf6f86b62019-06-10 23:19:12290 results.extend(_CheckOptimizeSVGHashes(input_api, output_api))
Blink Reformat4c46d092018-04-07 15:32:37291 results.extend(_CheckCSSViolations(input_api, output_api))
Yang Guoa7845d52019-10-31 10:30:23292 results.extend(_CheckChangesAreExclusiveToDirectory(input_api, output_api))
Tim van der Lippe5279f842020-01-14 16:26:38293 results.extend(_CheckNoUncheckedFiles(input_api, output_api))
Tim van der Lippe8fdda112020-01-27 11:27:06294 results.extend(_CheckForTooLargeFiles(input_api, output_api))
Blink Reformat4c46d092018-04-07 15:32:37295 return results
296
297
Liviu Raud614e092020-01-08 09:56:33298def CheckChangeOnUpload(input_api, output_api):
299 results = []
300 results.extend(_CommonChecks(input_api, output_api))
301 results.extend(_CheckDevtoolsLocalization(input_api, output_api))
302 return results
303
304
Blink Reformat4c46d092018-04-07 15:32:37305def CheckChangeOnCommit(input_api, output_api):
Mandy Chenf0fbdbe2019-08-22 23:58:37306 results = []
Yang Guo4fd355c2019-09-19 08:59:03307 results.extend(_CommonChecks(input_api, output_api))
e52a82bdfb5106bd658c2c5ea465e200594be1e2019-10-29 23:02:46308 results.extend(_CheckDevtoolsLocalization(input_api, output_api, True))
Mathias Bynens032591d2019-10-21 09:51:31309 results.extend(input_api.canned_checks.CheckChangeHasDescription(input_api, output_api))
Mandy Chenf0fbdbe2019-08-22 23:58:37310 return results
Blink Reformat4c46d092018-04-07 15:32:37311
312
Mandy Chena6be46a2019-07-09 17:06:27313def _getAffectedFiles(input_api, parent_directories, excluded_actions, accepted_endings): # pylint: disable=invalid-name
Yang Guo75beda92019-10-28 07:29:25314 """Return absolute file paths of affected files (not due to an excluded action)
Mandy Chena6be46a2019-07-09 17:06:27315 under a parent directory with an accepted file ending.
Yang Guo75beda92019-10-28 07:29:25316 """
Mandy Chena6be46a2019-07-09 17:06:27317 local_paths = [
318 f.AbsoluteLocalPath() for f in input_api.AffectedFiles() if all(f.Action() != action for action in excluded_actions)
319 ]
320 affected_files = [
321 file_name for file_name in local_paths
322 if any(parent_directory in file_name for parent_directory in parent_directories) and any(
323 file_name.endswith(accepted_ending) for accepted_ending in accepted_endings)
324 ]
325 return affected_files
326
327
Blink Reformat4c46d092018-04-07 15:32:37328def _getAffectedFrontEndFiles(input_api):
Blink Reformat4c46d092018-04-07 15:32:37329 devtools_root = input_api.PresubmitLocalPath()
Yang Guo75beda92019-10-28 07:29:25330 devtools_front_end = input_api.os_path.join(devtools_root, 'front_end')
331 affected_front_end_files = _getAffectedFiles(input_api, [devtools_front_end], ['D'], ['.js'])
Blink Reformat4c46d092018-04-07 15:32:37332 return [input_api.os_path.relpath(file_name, devtools_root) for file_name in affected_front_end_files]
333
334
335def _getAffectedJSFiles(input_api):
Blink Reformat4c46d092018-04-07 15:32:37336 devtools_root = input_api.PresubmitLocalPath()
Yang Guo75beda92019-10-28 07:29:25337 devtools_front_end = input_api.os_path.join(devtools_root, 'front_end')
338 devtools_scripts = input_api.os_path.join(devtools_root, 'scripts')
339 affected_js_files = _getAffectedFiles(input_api, [devtools_front_end, devtools_scripts], ['D'], ['.js'])
Blink Reformat4c46d092018-04-07 15:32:37340 return [input_api.os_path.relpath(file_name, devtools_root) for file_name in affected_js_files]
341
342
Lorne Mitchellc56ff2d2019-05-28 23:35:03343def _checkWithNodeScript(input_api, output_api, script_path, script_arguments=None): # pylint: disable=invalid-name
Blink Reformat4c46d092018-04-07 15:32:37344 original_sys_path = sys.path
345 try:
Yang Guo75beda92019-10-28 07:29:25346 sys.path = sys.path + [input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts')]
Yang Guod8176982019-10-04 20:30:35347 import devtools_paths
Blink Reformat4c46d092018-04-07 15:32:37348 finally:
349 sys.path = original_sys_path
350
Yang Guod8176982019-10-04 20:30:35351 node_path = devtools_paths.node_path()
Blink Reformat4c46d092018-04-07 15:32:37352
Lorne Mitchellc56ff2d2019-05-28 23:35:03353 if script_arguments is None:
354 script_arguments = []
Mandy Chen465b4f72019-03-21 22:52:54355
Blink Reformat4c46d092018-04-07 15:32:37356 process = input_api.subprocess.Popen(
Lorne Mitchellc56ff2d2019-05-28 23:35:03357 [node_path, script_path] + script_arguments, stdout=input_api.subprocess.PIPE, stderr=input_api.subprocess.STDOUT)
Blink Reformat4c46d092018-04-07 15:32:37358 out, _ = process.communicate()
359
360 if process.returncode != 0:
361 return [output_api.PresubmitError(out)]
362 return [output_api.PresubmitNotifyResult(out)]