Chromium Code Reviews| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 | 350 |
| 351 for line_num, line in f.ChangedContents(): | 351 for line_num, line in f.ChangedContents(): |
| 352 if 'UNIT_TEST ' in line or line.endswith('UNIT_TEST'): | 352 if 'UNIT_TEST ' in line or line.endswith('UNIT_TEST'): |
| 353 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | 353 problems.append(' %s:%d' % (f.LocalPath(), line_num)) |
| 354 | 354 |
| 355 if not problems: | 355 if not problems: |
| 356 return [] | 356 return [] |
| 357 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' + | 357 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' + |
| 358 '\n'.join(problems))] | 358 '\n'.join(problems))] |
| 359 | 359 |
| 360 def _CheckForOverrideAndFinalRules(input_api, output_api): | |
| 361 """Checks for override and final used as per C++11""" | |
| 362 problems = [] | |
| 363 for f in input_api.AffectedFiles(): | |
| 364 if (f.LocalPath().endswith(('.cc', '.mm', '.cpp', '.h'))): | |
| 365 for line_num, line in f.ChangedContents(): | |
| 366 if ' OVERRIDE' or ' FINAL' in line: | |
| 367 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | |
| 368 | |
| 369 if not problems: | |
| 370 return [] | |
| 371 return [output_api.PresubmitPromptWarning('Use OVERRIDE as overirde and ' | |
| 372 'FINAL as final as per C++11 \n' + | |
|
Avi (use Gerrit)
2014/10/09 15:30:22
This is awkward and mis-spelled English. I would p
MRV
2014/10/10 03:06:04
Done.
| |
| 373 '\n'.join(problems))] | |
| 360 | 374 |
| 361 def _CheckNoNewWStrings(input_api, output_api): | 375 def _CheckNoNewWStrings(input_api, output_api): |
| 362 """Checks to make sure we don't introduce use of wstrings.""" | 376 """Checks to make sure we don't introduce use of wstrings.""" |
| 363 problems = [] | 377 problems = [] |
| 364 for f in input_api.AffectedFiles(): | 378 for f in input_api.AffectedFiles(): |
| 365 if (not f.LocalPath().endswith(('.cc', '.h')) or | 379 if (not f.LocalPath().endswith(('.cc', '.h')) or |
| 366 f.LocalPath().endswith(('test.cc', '_win.cc', '_win.h'))): | 380 f.LocalPath().endswith(('test.cc', '_win.cc', '_win.h'))): |
| 367 continue | 381 continue |
| 368 | 382 |
| 369 allowWString = False | 383 allowWString = False |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1293 input_api, | 1307 input_api, |
| 1294 output_api, | 1308 output_api, |
| 1295 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 1309 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) |
| 1296 results.extend(_CheckSpamLogging(input_api, output_api)) | 1310 results.extend(_CheckSpamLogging(input_api, output_api)) |
| 1297 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1311 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
| 1298 results.extend(_CheckCygwinShell(input_api, output_api)) | 1312 results.extend(_CheckCygwinShell(input_api, output_api)) |
| 1299 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1313 results.extend(_CheckUserActionUpdate(input_api, output_api)) |
| 1300 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 1314 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) |
| 1301 results.extend(_CheckParseErrors(input_api, output_api)) | 1315 results.extend(_CheckParseErrors(input_api, output_api)) |
| 1302 results.extend(_CheckForIPCRules(input_api, output_api)) | 1316 results.extend(_CheckForIPCRules(input_api, output_api)) |
| 1317 results.extend(_CheckForOverrideAndFinalRules(input_api, output_api)) | |
| 1303 | 1318 |
| 1304 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1319 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
| 1305 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1320 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 1306 input_api, output_api, | 1321 input_api, output_api, |
| 1307 input_api.PresubmitLocalPath(), | 1322 input_api.PresubmitLocalPath(), |
| 1308 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1323 whitelist=[r'^PRESUBMIT_test\.py$'])) |
| 1309 return results | 1324 return results |
| 1310 | 1325 |
| 1311 | 1326 |
| 1312 def _CheckAuthorizedAuthor(input_api, output_api): | 1327 def _CheckAuthorizedAuthor(input_api, output_api): |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1715 builders.extend(['cros_x86']) | 1730 builders.extend(['cros_x86']) |
| 1716 | 1731 |
| 1717 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1732 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it |
| 1718 # unless they're .gyp(i) files as changes to those files can break the gyp | 1733 # unless they're .gyp(i) files as changes to those files can break the gyp |
| 1719 # step on that bot. | 1734 # step on that bot. |
| 1720 if (not all(re.search('^chrome', f) for f in files) or | 1735 if (not all(re.search('^chrome', f) for f in files) or |
| 1721 any(re.search('\.gypi?$', f) for f in files)): | 1736 any(re.search('\.gypi?$', f) for f in files)): |
| 1722 builders.extend(['android_aosp']) | 1737 builders.extend(['android_aosp']) |
| 1723 | 1738 |
| 1724 return GetDefaultTryConfigs(builders) | 1739 return GetDefaultTryConfigs(builders) |
| OLD | NEW |