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

Side by Side Diff: PRESUBMIT.py

Issue 1129443005: Add presubmit to run `{dm,nanobench}_flags.py test` when changed. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: python Created 5 years, 7 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 | tools/dm_flags.json » ('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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 for affected_file in input_api.AffectedSourceFiles(source_file_filter): 133 for affected_file in input_api.AffectedSourceFiles(source_file_filter):
134 if 'third_party' in affected_file.LocalPath(): 134 if 'third_party' in affected_file.LocalPath():
135 continue 135 continue
136 contents = input_api.ReadFile(affected_file, 'rb') 136 contents = input_api.ReadFile(affected_file, 'rb')
137 if not re.search(copyright_pattern, contents): 137 if not re.search(copyright_pattern, contents):
138 results.append(output_api.PresubmitError( 138 results.append(output_api.PresubmitError(
139 '%s is missing a correct copyright header.' % affected_file)) 139 '%s is missing a correct copyright header.' % affected_file))
140 return results 140 return results
141 141
142 142
143 def _ToolFlags(input_api, output_api):
144 """Make sure `{dm,nanobench}_flags.py test` passes if modified."""
145 results = []
146 sources = lambda x: ('dm_flags.py' in x.LocalPath() or
147 'nanobench_flags.py' in x.LocalPath())
148 for f in input_api.AffectedSourceFiles(sources):
149 if 0 != subprocess.call(['python', f.LocalPath(), 'test']):
150 results.append(output_api.PresubmitError('`python %s test` failed' % f))
151 return results
152
153
143 def _CommonChecks(input_api, output_api): 154 def _CommonChecks(input_api, output_api):
144 """Presubmit checks common to upload and commit.""" 155 """Presubmit checks common to upload and commit."""
145 results = [] 156 results = []
146 sources = lambda x: (x.LocalPath().endswith('.h') or 157 sources = lambda x: (x.LocalPath().endswith('.h') or
147 x.LocalPath().endswith('.gypi') or 158 x.LocalPath().endswith('.gypi') or
148 x.LocalPath().endswith('.gyp') or 159 x.LocalPath().endswith('.gyp') or
149 x.LocalPath().endswith('.py') or 160 x.LocalPath().endswith('.py') or
150 x.LocalPath().endswith('.sh') or 161 x.LocalPath().endswith('.sh') or
151 x.LocalPath().endswith('.m') or 162 x.LocalPath().endswith('.m') or
152 x.LocalPath().endswith('.mm') or 163 x.LocalPath().endswith('.mm') or
153 x.LocalPath().endswith('.go') or 164 x.LocalPath().endswith('.go') or
154 x.LocalPath().endswith('.c') or 165 x.LocalPath().endswith('.c') or
155 x.LocalPath().endswith('.cc') or 166 x.LocalPath().endswith('.cc') or
156 x.LocalPath().endswith('.cpp')) 167 x.LocalPath().endswith('.cpp'))
157 results.extend( 168 results.extend(
158 _CheckChangeHasEol( 169 _CheckChangeHasEol(
159 input_api, output_api, source_file_filter=sources)) 170 input_api, output_api, source_file_filter=sources))
160 results.extend(_PythonChecks(input_api, output_api)) 171 results.extend(_PythonChecks(input_api, output_api))
161 results.extend(_IfDefChecks(input_api, output_api)) 172 results.extend(_IfDefChecks(input_api, output_api))
162 results.extend(_CopyrightChecks(input_api, output_api, 173 results.extend(_CopyrightChecks(input_api, output_api,
163 source_file_filter=sources)) 174 source_file_filter=sources))
175 results.extend(_ToolFlags(input_api, output_api))
164 return results 176 return results
165 177
166 178
167 def CheckChangeOnUpload(input_api, output_api): 179 def CheckChangeOnUpload(input_api, output_api):
168 """Presubmit checks for the change on upload. 180 """Presubmit checks for the change on upload.
169 181
170 The following are the presubmit checks: 182 The following are the presubmit checks:
171 * Check change has one and only one EOL. 183 * Check change has one and only one EOL.
172 """ 184 """
173 results = [] 185 results = []
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 state and an error if it is in 'Closed' state. 477 state and an error if it is in 'Closed' state.
466 """ 478 """
467 results = [] 479 results = []
468 results.extend(_CommonChecks(input_api, output_api)) 480 results.extend(_CommonChecks(input_api, output_api))
469 results.extend( 481 results.extend(
470 _CheckTreeStatus(input_api, output_api, json_url=( 482 _CheckTreeStatus(input_api, output_api, json_url=(
471 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) 483 SKIA_TREE_STATUS_URL + '/banner-status?format=json')))
472 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) 484 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api))
473 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) 485 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api))
474 return results 486 return results
OLDNEW
« no previous file with comments | « no previous file | tools/dm_flags.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698