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

Side by Side Diff: PRESUBMIT.py

Issue 2415193002: Add infra_tests.py, recipe, buildbotless bot (Closed)
Patch Set: Fixes Created 4 years, 2 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 | infra/bots/assets/asset_utils_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 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 5
6 """Top-level presubmit script for Skia. 6 """Top-level presubmit script for Skia.
7 7
8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
9 for more details about the presubmit API built into gcl. 9 for more details about the presubmit API built into gcl.
10 """ 10 """
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 """Make sure `{dm,nanobench}_flags.py test` passes if modified.""" 160 """Make sure `{dm,nanobench}_flags.py test` passes if modified."""
161 results = [] 161 results = []
162 sources = lambda x: ('dm_flags.py' in x.LocalPath() or 162 sources = lambda x: ('dm_flags.py' in x.LocalPath() or
163 'nanobench_flags.py' in x.LocalPath()) 163 'nanobench_flags.py' in x.LocalPath())
164 for f in input_api.AffectedSourceFiles(sources): 164 for f in input_api.AffectedSourceFiles(sources):
165 if 0 != subprocess.call(['python', f.LocalPath(), 'test']): 165 if 0 != subprocess.call(['python', f.LocalPath(), 'test']):
166 results.append(output_api.PresubmitError('`python %s test` failed' % f)) 166 results.append(output_api.PresubmitError('`python %s test` failed' % f))
167 return results 167 return results
168 168
169 169
170 def _RecipeSimulationTest(input_api, output_api): 170 def _InfraTests(input_api, output_api):
171 """Run the recipe simulation test.""" 171 """Run the infra tests."""
172 results = [] 172 results = []
173 if not any(f.LocalPath().startswith('infra') 173 if not any(f.LocalPath().startswith('infra')
174 for f in input_api.AffectedFiles()): 174 for f in input_api.AffectedFiles()):
175 return results 175 return results
176 176
177 recipes_py = os.path.join('infra', 'bots', 'recipes.py') 177 cmd = ['python', os.path.join('infra', 'bots', 'infra_tests.py')]
178 cmd = ['python', recipes_py, 'simulation_test']
179 try: 178 try:
180 subprocess.check_output(cmd) 179 subprocess.check_output(cmd)
181 except subprocess.CalledProcessError as e: 180 except subprocess.CalledProcessError as e:
182 results.append(output_api.PresubmitError(
183 '`%s` failed:\n%s' % (' '.join(cmd), e.output)))
184 return results
185
186
187 def _GenTasksTest(input_api, output_api):
188 """Run gen_tasks.go test."""
189 results = []
190 if not any(f.LocalPath().startswith('infra')
191 for f in input_api.AffectedFiles()):
192 return results
193
194 gen_tasks = os.path.join('infra', 'bots', 'gen_tasks.go')
195 cmd = ['go', 'run', gen_tasks, '--test']
196 try:
197 subprocess.check_output(cmd)
198 except subprocess.CalledProcessError as e:
199 results.append(output_api.PresubmitError( 181 results.append(output_api.PresubmitError(
200 '`%s` failed:\n%s' % (' '.join(cmd), e.output))) 182 '`%s` failed:\n%s' % (' '.join(cmd), e.output)))
201 return results 183 return results
202 184
203 185
204 def _CheckGNFormatted(input_api, output_api): 186 def _CheckGNFormatted(input_api, output_api):
205 """Make sure any .gn files we're changing have been formatted.""" 187 """Make sure any .gn files we're changing have been formatted."""
206 results = [] 188 results = []
207 for f in input_api.AffectedFiles(): 189 for f in input_api.AffectedFiles():
208 if not f.LocalPath().endswith('.gn'): 190 if not f.LocalPath().endswith('.gn'):
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 def CheckChangeOnUpload(input_api, output_api): 229 def CheckChangeOnUpload(input_api, output_api):
248 """Presubmit checks for the change on upload. 230 """Presubmit checks for the change on upload.
249 231
250 The following are the presubmit checks: 232 The following are the presubmit checks:
251 * Check change has one and only one EOL. 233 * Check change has one and only one EOL.
252 """ 234 """
253 results = [] 235 results = []
254 results.extend(_CommonChecks(input_api, output_api)) 236 results.extend(_CommonChecks(input_api, output_api))
255 # Run on upload, not commit, since the presubmit bot apparently doesn't have 237 # Run on upload, not commit, since the presubmit bot apparently doesn't have
256 # coverage or Go installed. 238 # coverage or Go installed.
257 results.extend(_RecipeSimulationTest(input_api, output_api)) 239 results.extend(_InfraTests(input_api, output_api))
258 results.extend(_GenTasksTest(input_api, output_api))
259 240
260 results.extend(_CheckGNFormatted(input_api, output_api)) 241 results.extend(_CheckGNFormatted(input_api, output_api))
261 return results 242 return results
262 243
263 244
264 def _CheckTreeStatus(input_api, output_api, json_url): 245 def _CheckTreeStatus(input_api, output_api, json_url):
265 """Check whether to allow commit. 246 """Check whether to allow commit.
266 247
267 Args: 248 Args:
268 input_api: input related apis. 249 input_api: input related apis.
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 state and an error if it is in 'Closed' state. 624 state and an error if it is in 'Closed' state.
644 """ 625 """
645 results = [] 626 results = []
646 results.extend(_CommonChecks(input_api, output_api)) 627 results.extend(_CommonChecks(input_api, output_api))
647 results.extend( 628 results.extend(
648 _CheckTreeStatus(input_api, output_api, json_url=( 629 _CheckTreeStatus(input_api, output_api, json_url=(
649 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) 630 SKIA_TREE_STATUS_URL + '/banner-status?format=json')))
650 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) 631 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api))
651 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) 632 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api))
652 return results 633 return results
OLDNEW
« no previous file with comments | « no previous file | infra/bots/assets/asset_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698