OLD | NEW |
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if 'ScopedAllowIO' in line: | 193 if 'ScopedAllowIO' in line: |
194 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | 194 problems.append(' %s:%d' % (f.LocalPath(), line_num)) |
195 | 195 |
196 if not problems: | 196 if not problems: |
197 return [] | 197 return [] |
198 return [output_api.PresubmitPromptWarning('New code should not use ' | 198 return [output_api.PresubmitPromptWarning('New code should not use ' |
199 'ScopedAllowIO. Post a task to the blocking pool or the FILE thread ' | 199 'ScopedAllowIO. Post a task to the blocking pool or the FILE thread ' |
200 'instead.\n' + '\n'.join(problems))] | 200 'instead.\n' + '\n'.join(problems))] |
201 | 201 |
202 | 202 |
| 203 def _CheckNoFilePathWatcherDelegate(input_api, output_api): |
| 204 """Make sure that FilePathWatcher::Delegate is not used.""" |
| 205 problems = [] |
| 206 |
| 207 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h')) |
| 208 for f in input_api.AffectedFiles(file_filter=file_filter): |
| 209 for line_num, line in f.ChangedContents(): |
| 210 if 'FilePathWatcher::Delegate' in line: |
| 211 problems.append(' %s:%d' % (f.LocalPath(), line_num)) |
| 212 |
| 213 if not problems: |
| 214 return [] |
| 215 return [output_api.PresubmitPromptWarning('New code should not use ' |
| 216 'FilePathWatcher::Delegate. Use the callback interface instead.\n' + |
| 217 '\n'.join(problems))] |
| 218 |
| 219 |
203 def _CommonChecks(input_api, output_api): | 220 def _CommonChecks(input_api, output_api): |
204 """Checks common to both upload and commit.""" | 221 """Checks common to both upload and commit.""" |
205 results = [] | 222 results = [] |
206 results.extend(input_api.canned_checks.PanProjectChecks( | 223 results.extend(input_api.canned_checks.PanProjectChecks( |
207 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) | 224 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) |
208 results.extend(_CheckNoInterfacesInBase(input_api, output_api)) | 225 results.extend(_CheckNoInterfacesInBase(input_api, output_api)) |
209 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 226 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) |
210 results.extend( | 227 results.extend( |
211 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 228 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) |
212 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 229 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
213 results.extend(_CheckNoNewWStrings(input_api, output_api)) | 230 results.extend(_CheckNoNewWStrings(input_api, output_api)) |
214 results.extend(_CheckNoDEPSGIT(input_api, output_api)) | 231 results.extend(_CheckNoDEPSGIT(input_api, output_api)) |
215 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) | 232 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) |
216 results.extend(_CheckNoScopedAllowIO(input_api, output_api)) | 233 results.extend(_CheckNoScopedAllowIO(input_api, output_api)) |
| 234 results.extend(_CheckNoFilePathWatcherDelegate(input_api, output_api)) |
217 return results | 235 return results |
218 | 236 |
219 | 237 |
220 def _CheckSubversionConfig(input_api, output_api): | 238 def _CheckSubversionConfig(input_api, output_api): |
221 """Verifies the subversion config file is correctly setup. | 239 """Verifies the subversion config file is correctly setup. |
222 | 240 |
223 Checks that autoprops are enabled, returns an error otherwise. | 241 Checks that autoprops are enabled, returns an error otherwise. |
224 """ | 242 """ |
225 join = input_api.os_path.join | 243 join = input_api.os_path.join |
226 if input_api.platform == 'win32': | 244 if input_api.platform == 'win32': |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 for non_android_re in (aura_re, win_re): | 365 for non_android_re in (aura_re, win_re): |
348 if all(re.search(non_android_re, f) for f in affected_files): | 366 if all(re.search(non_android_re, f) for f in affected_files): |
349 possibly_android = False | 367 possibly_android = False |
350 break | 368 break |
351 if possibly_android: | 369 if possibly_android: |
352 for f in change.AffectedFiles(): | 370 for f in change.AffectedFiles(): |
353 if any(re.search(r, f.LocalPath()) for r in android_re_list): | 371 if any(re.search(r, f.LocalPath()) for r in android_re_list): |
354 preferred.append('android') | 372 preferred.append('android') |
355 break | 373 break |
356 return preferred | 374 return preferred |
OLD | NEW |