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

Side by Side Diff: PRESUBMIT.py

Issue 9423025: PRESUBMIT doesn't need to check for old callback system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« 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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Top-level presubmit script for Chromium. 5 """Top-level presubmit script for Chromium.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl. 8 for more details about the presubmit API built into gcl.
9 """ 9 """
10 10
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if 'FRIEND_TEST(' in line: 175 if 'FRIEND_TEST(' in line:
176 problems.append(' %s:%d' % (f.LocalPath(), line_num)) 176 problems.append(' %s:%d' % (f.LocalPath(), line_num))
177 177
178 if not problems: 178 if not problems:
179 return [] 179 return []
180 return [output_api.PresubmitPromptWarning('Chromium code should not use ' 180 return [output_api.PresubmitPromptWarning('Chromium code should not use '
181 'gtest\'s FRIEND_TEST() macro. Include base/gtest_prod_util.h and use ' 181 'gtest\'s FRIEND_TEST() macro. Include base/gtest_prod_util.h and use '
182 'FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))] 182 'FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))]
183 183
184 184
185 def _CheckNoNewOldCallback(input_api, output_api):
186 """Checks to make sure we don't introduce new uses of old callbacks."""
187
188 def HasOldCallbackKeywords(line):
189 """Returns True if a line of text contains keywords that indicate the use
190 of the old callback system.
191 """
192 return ('NewRunnableMethod' in line or
193 'NewCallback' in line or
194 input_api.re.search(r'\bCallback\d<', line) or
195 input_api.re.search(r'\bpublic Task\b', line) or
196 'public CancelableTask' in line)
197
198 problems = []
199 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h'))
200 for f in input_api.AffectedFiles(file_filter=file_filter):
201 if not any(HasOldCallbackKeywords(line) for line in f.NewContents()):
202 continue
203 for line_num, line in f.ChangedContents():
204 if HasOldCallbackKeywords(line):
205 problems.append(' %s:%d' % (f.LocalPath(), line_num))
206
207 if not problems:
208 return []
209 return [output_api.PresubmitPromptWarning('The old callback system is '
210 'deprecated. If possible, use base::Bind and base::Callback instead.\n' +
211 '\n'.join(problems))]
212
213
214 def _CommonChecks(input_api, output_api): 185 def _CommonChecks(input_api, output_api):
215 """Checks common to both upload and commit.""" 186 """Checks common to both upload and commit."""
216 results = [] 187 results = []
217 results.extend(input_api.canned_checks.PanProjectChecks( 188 results.extend(input_api.canned_checks.PanProjectChecks(
218 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) 189 input_api, output_api, excluded_paths=_EXCLUDED_PATHS))
219 results.extend(_CheckNoInterfacesInBase(input_api, output_api)) 190 results.extend(_CheckNoInterfacesInBase(input_api, output_api))
220 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) 191 results.extend(_CheckAuthorizedAuthor(input_api, output_api))
221 results.extend( 192 results.extend(
222 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) 193 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
223 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) 194 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
224 results.extend(_CheckNoNewWStrings(input_api, output_api)) 195 results.extend(_CheckNoNewWStrings(input_api, output_api))
225 results.extend(_CheckNoDEPSGIT(input_api, output_api)) 196 results.extend(_CheckNoDEPSGIT(input_api, output_api))
226 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) 197 results.extend(_CheckNoFRIEND_TEST(input_api, output_api))
227 results.extend(_CheckNoNewOldCallback(input_api, output_api))
228 return results 198 return results
229 199
230 200
231 def _CheckSubversionConfig(input_api, output_api): 201 def _CheckSubversionConfig(input_api, output_api):
232 """Verifies the subversion config file is correctly setup. 202 """Verifies the subversion config file is correctly setup.
233 203
234 Checks that autoprops are enabled, returns an error otherwise. 204 Checks that autoprops are enabled, returns an error otherwise.
235 """ 205 """
236 join = input_api.os_path.join 206 join = input_api.os_path.join
237 if input_api.platform == 'win32': 207 if input_api.platform == 'win32':
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 # 2 trybots (compared against ~45 for Mac and Linux). 321 # 2 trybots (compared against ~45 for Mac and Linux).
352 # If any file matches something compiled on the main waterfall 322 # If any file matches something compiled on the main waterfall
353 # android builder, use the android try server. 323 # android builder, use the android try server.
354 android_re_list = ('^base/', '^ipc/', '^net/', '^sql/', '^jingle/', 324 android_re_list = ('^base/', '^ipc/', '^net/', '^sql/', '^jingle/',
355 '^build/common.gypi$') 325 '^build/common.gypi$')
356 for f in affected_files: 326 for f in affected_files:
357 if any(re.search(r, f) for r in android_re_list): 327 if any(re.search(r, f) for r in android_re_list):
358 preferred.append('android') 328 preferred.append('android')
359 break 329 break
360 return preferred 330 return preferred
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