| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 'Do not introduce new v8::Extensions into the code base, use', | 244 'Do not introduce new v8::Extensions into the code base, use', |
| 245 'gin::Wrappable instead. See http://crbug.com/334679', | 245 'gin::Wrappable instead. See http://crbug.com/334679', |
| 246 ), | 246 ), |
| 247 True, | 247 True, |
| 248 ( | 248 ( |
| 249 r'extensions[\\\/]renderer[\\\/]safe_builtins\.*', | 249 r'extensions[\\\/]renderer[\\\/]safe_builtins\.*', |
| 250 ), | 250 ), |
| 251 ), | 251 ), |
| 252 ) | 252 ) |
| 253 | 253 |
| 254 _IPC_ENUM_TRAITS_DEPRECATED = ( |
| 255 'You are using IPC_ENUM_TRAITS() in your code. It has been deprecated.\n' |
| 256 'See http://www.chromium.org/Home/chromium-security/education/security-tips-
for-ipc') |
| 257 |
| 254 | 258 |
| 255 _VALID_OS_MACROS = ( | 259 _VALID_OS_MACROS = ( |
| 256 # Please keep sorted. | 260 # Please keep sorted. |
| 257 'OS_ANDROID', | 261 'OS_ANDROID', |
| 258 'OS_ANDROID_HOST', | 262 'OS_ANDROID_HOST', |
| 259 'OS_BSD', | 263 'OS_BSD', |
| 260 'OS_CAT', # For testing. | 264 'OS_CAT', # For testing. |
| 261 'OS_CHROMEOS', | 265 'OS_CHROMEOS', |
| 262 'OS_FREEBSD', | 266 'OS_FREEBSD', |
| 263 'OS_IOS', | 267 'OS_IOS', |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 input_api.canned_checks.CheckChangeHasNoTabs( | 1273 input_api.canned_checks.CheckChangeHasNoTabs( |
| 1270 input_api, | 1274 input_api, |
| 1271 output_api, | 1275 output_api, |
| 1272 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 1276 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) |
| 1273 results.extend(_CheckSpamLogging(input_api, output_api)) | 1277 results.extend(_CheckSpamLogging(input_api, output_api)) |
| 1274 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1278 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
| 1275 results.extend(_CheckCygwinShell(input_api, output_api)) | 1279 results.extend(_CheckCygwinShell(input_api, output_api)) |
| 1276 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1280 results.extend(_CheckUserActionUpdate(input_api, output_api)) |
| 1277 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 1281 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) |
| 1278 results.extend(_CheckParseErrors(input_api, output_api)) | 1282 results.extend(_CheckParseErrors(input_api, output_api)) |
| 1283 results.extend(_CheckForIPCRules(input_api, output_api)) |
| 1279 | 1284 |
| 1280 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1285 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
| 1281 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1286 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 1282 input_api, output_api, | 1287 input_api, output_api, |
| 1283 input_api.PresubmitLocalPath(), | 1288 input_api.PresubmitLocalPath(), |
| 1284 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1289 whitelist=[r'^PRESUBMIT_test\.py$'])) |
| 1285 return results | 1290 return results |
| 1286 | 1291 |
| 1287 | 1292 |
| 1288 def _CheckAuthorizedAuthor(input_api, output_api): | 1293 def _CheckAuthorizedAuthor(input_api, output_api): |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 if not f.LocalPath().endswith(('.py', '.js', '.html', '.css')): | 1371 if not f.LocalPath().endswith(('.py', '.js', '.html', '.css')): |
| 1367 bad_macros.extend(_CheckForInvalidOSMacrosInFile(input_api, f)) | 1372 bad_macros.extend(_CheckForInvalidOSMacrosInFile(input_api, f)) |
| 1368 | 1373 |
| 1369 if not bad_macros: | 1374 if not bad_macros: |
| 1370 return [] | 1375 return [] |
| 1371 | 1376 |
| 1372 return [output_api.PresubmitError( | 1377 return [output_api.PresubmitError( |
| 1373 'Possibly invalid OS macro[s] found. Please fix your code\n' | 1378 'Possibly invalid OS macro[s] found. Please fix your code\n' |
| 1374 'or add your macro to src/PRESUBMIT.py.', bad_macros)] | 1379 'or add your macro to src/PRESUBMIT.py.', bad_macros)] |
| 1375 | 1380 |
| 1381 def _CheckForIPCRules(input_api, output_api): |
| 1382 """Check for same IPC rules described in |
| 1383 http://www.chromium.org/Home/chromium-security/education/security-tips-for-ipc |
| 1384 """ |
| 1385 base_pattern = r'IPC_ENUM_TRAITS\(' |
| 1386 inclusion_pattern = input_api.re.compile(r'(%s)' % base_pattern) |
| 1387 comment_pattern = input_api.re.compile(r'//.*(%s)' % base_pattern) |
| 1388 |
| 1389 problems = [] |
| 1390 for f in input_api.AffectedSourceFiles(None): |
| 1391 local_path = f.LocalPath() |
| 1392 if not local_path.endswith('.h'): |
| 1393 continue |
| 1394 for line_number, line in f.ChangedContents(): |
| 1395 if inclusion_pattern.search(line) and not comment_pattern.search(line): |
| 1396 problems.append( |
| 1397 '%s:%d\n %s' % (local_path, line_number, line.strip())) |
| 1398 |
| 1399 if problems: |
| 1400 return [output_api.PresubmitPromptWarning( |
| 1401 _IPC_ENUM_TRAITS_DEPRECATED, problems)] |
| 1402 else: |
| 1403 return [] |
| 1404 |
| 1376 | 1405 |
| 1377 def CheckChangeOnUpload(input_api, output_api): | 1406 def CheckChangeOnUpload(input_api, output_api): |
| 1378 results = [] | 1407 results = [] |
| 1379 results.extend(_CommonChecks(input_api, output_api)) | 1408 results.extend(_CommonChecks(input_api, output_api)) |
| 1380 results.extend(_CheckJavaStyle(input_api, output_api)) | 1409 results.extend(_CheckJavaStyle(input_api, output_api)) |
| 1381 return results | 1410 return results |
| 1382 | 1411 |
| 1383 | 1412 |
| 1384 def GetTryServerMasterForBot(bot): | 1413 def GetTryServerMasterForBot(bot): |
| 1385 """Returns the Try Server master for the given bot. | 1414 """Returns the Try Server master for the given bot. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 builders.extend(['cros_x86']) | 1618 builders.extend(['cros_x86']) |
| 1590 | 1619 |
| 1591 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1620 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it |
| 1592 # unless they're .gyp(i) files as changes to those files can break the gyp | 1621 # unless they're .gyp(i) files as changes to those files can break the gyp |
| 1593 # step on that bot. | 1622 # step on that bot. |
| 1594 if (not all(re.search('^chrome', f) for f in files) or | 1623 if (not all(re.search('^chrome', f) for f in files) or |
| 1595 any(re.search('\.gypi?$', f) for f in files)): | 1624 any(re.search('\.gypi?$', f) for f in files)): |
| 1596 builders.extend(['android_aosp']) | 1625 builders.extend(['android_aosp']) |
| 1597 | 1626 |
| 1598 return GetDefaultTryConfigs(builders) | 1627 return GetDefaultTryConfigs(builders) |
| OLD | NEW |