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 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1252 f, white_list=file_inclusion_pattern, black_list=black_list) | 1252 f, white_list=file_inclusion_pattern, black_list=black_list) |
1253 for fpath in input_api.AffectedFiles(file_filter=file_filter): | 1253 for fpath in input_api.AffectedFiles(file_filter=file_filter): |
1254 for line_num, line in fpath.ChangedContents(): | 1254 for line_num, line in fpath.ChangedContents(): |
1255 for (deprecated_value, value) in _DEPRECATED_CSS: | 1255 for (deprecated_value, value) in _DEPRECATED_CSS: |
1256 if input_api.re.search(deprecated_value, line): | 1256 if input_api.re.search(deprecated_value, line): |
1257 results.append(output_api.PresubmitError( | 1257 results.append(output_api.PresubmitError( |
1258 "%s:%d: Use of deprecated CSS %s, use %s instead" % | 1258 "%s:%d: Use of deprecated CSS %s, use %s instead" % |
1259 (fpath.LocalPath(), line_num, deprecated_value, value))) | 1259 (fpath.LocalPath(), line_num, deprecated_value, value))) |
1260 return results | 1260 return results |
1261 | 1261 |
1262 def _CheckForOverrideAndFinalRules(input_api, output_api): | |
1263 """Checks for override and final used as per C++11""" | |
1264 override_pattern = "OVERRIDE" | |
1265 final_pattern = "FINAL" | |
1266 problems = [] | |
1267 for f in input_api.AffectedFiles(): | |
1268 if (f.LocalPath().endswith(('.cc', '.mm', '.cpp', '.h'))): | |
1269 for line_num, line in f.ChangedContents(): | |
1270 if (re.search(r"\b" + override_pattern + r"\b", line) or | |
Mike West
2014/10/14 10:35:54
I'd suggest simply inlining the patterns here: r"\
MRV
2014/10/14 11:50:16
Done.
| |
1271 re.search(r"\b" + final_pattern + r"\b", line)): | |
1272 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | |
1273 | |
1274 if not problems: | |
1275 return [] | |
1276 return [output_api.PresubmitError('Use C++11\'s |override| and' | |
1277 ' |final| rather than OVERRIDE and FINAL. \n' + | |
1278 '\n'.join(problems))] | |
1279 | |
1280 | |
1262 def _CommonChecks(input_api, output_api): | 1281 def _CommonChecks(input_api, output_api): |
1263 """Checks common to both upload and commit.""" | 1282 """Checks common to both upload and commit.""" |
1264 results = [] | 1283 results = [] |
1265 results.extend(input_api.canned_checks.PanProjectChecks( | 1284 results.extend(input_api.canned_checks.PanProjectChecks( |
1266 input_api, output_api, | 1285 input_api, output_api, |
1267 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) | 1286 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) |
1268 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 1287 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) |
1269 results.extend( | 1288 results.extend( |
1270 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 1289 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) |
1271 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 1290 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
(...skipping 21 matching lines...) Expand all Loading... | |
1293 input_api, | 1312 input_api, |
1294 output_api, | 1313 output_api, |
1295 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 1314 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) |
1296 results.extend(_CheckSpamLogging(input_api, output_api)) | 1315 results.extend(_CheckSpamLogging(input_api, output_api)) |
1297 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1316 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
1298 results.extend(_CheckCygwinShell(input_api, output_api)) | 1317 results.extend(_CheckCygwinShell(input_api, output_api)) |
1299 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1318 results.extend(_CheckUserActionUpdate(input_api, output_api)) |
1300 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 1319 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) |
1301 results.extend(_CheckParseErrors(input_api, output_api)) | 1320 results.extend(_CheckParseErrors(input_api, output_api)) |
1302 results.extend(_CheckForIPCRules(input_api, output_api)) | 1321 results.extend(_CheckForIPCRules(input_api, output_api)) |
1322 results.extend(_CheckForOverrideAndFinalRules(input_api, output_api)) | |
1303 | 1323 |
1304 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1324 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
1305 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1325 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
1306 input_api, output_api, | 1326 input_api, output_api, |
1307 input_api.PresubmitLocalPath(), | 1327 input_api.PresubmitLocalPath(), |
1308 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1328 whitelist=[r'^PRESUBMIT_test\.py$'])) |
1309 return results | 1329 return results |
1310 | 1330 |
1311 | 1331 |
1312 def _CheckAuthorizedAuthor(input_api, output_api): | 1332 def _CheckAuthorizedAuthor(input_api, output_api): |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1715 builders.extend(['cros_x86']) | 1735 builders.extend(['cros_x86']) |
1716 | 1736 |
1717 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1737 # 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 | 1738 # unless they're .gyp(i) files as changes to those files can break the gyp |
1719 # step on that bot. | 1739 # step on that bot. |
1720 if (not all(re.search('^chrome', f) for f in files) or | 1740 if (not all(re.search('^chrome', f) for f in files) or |
1721 any(re.search('\.gypi?$', f) for f in files)): | 1741 any(re.search('\.gypi?$', f) for f in files)): |
1722 builders.extend(['android_aosp']) | 1742 builders.extend(['android_aosp']) |
1723 | 1743 |
1724 return GetDefaultTryConfigs(builders) | 1744 return GetDefaultTryConfigs(builders) |
OLD | NEW |