| 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 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 ( "-webkit-radial-gradient", "radial-gradient" ), | 1232 ( "-webkit-radial-gradient", "radial-gradient" ), |
| 1233 ( "-webkit-repeating-radial-gradient", "repeating-radial-gradient" ), | 1233 ( "-webkit-repeating-radial-gradient", "repeating-radial-gradient" ), |
| 1234 ] | 1234 ] |
| 1235 | 1235 |
| 1236 def _CheckNoDeprecatedCSS(input_api, output_api): | 1236 def _CheckNoDeprecatedCSS(input_api, output_api): |
| 1237 """ Make sure that we don't use deprecated CSS | 1237 """ Make sure that we don't use deprecated CSS |
| 1238 properties, functions or values. Our external | 1238 properties, functions or values. Our external |
| 1239 documentation is ignored by the hooks as it | 1239 documentation is ignored by the hooks as it |
| 1240 needs to be consumed by WebKit. """ | 1240 needs to be consumed by WebKit. """ |
| 1241 results = [] | 1241 results = [] |
| 1242 file_inclusion_pattern = (r".+\.css$") | 1242 file_inclusion_pattern = (r".+\.css$",) |
| 1243 black_list = (_EXCLUDED_PATHS + | 1243 black_list = (_EXCLUDED_PATHS + |
| 1244 _TEST_CODE_EXCLUDED_PATHS + | 1244 _TEST_CODE_EXCLUDED_PATHS + |
| 1245 input_api.DEFAULT_BLACK_LIST + | 1245 input_api.DEFAULT_BLACK_LIST + |
| 1246 (r"^chrome/common/extensions/docs", | 1246 (r"^chrome/common/extensions/docs", |
| 1247 r"^chrome/docs", | 1247 r"^chrome/docs", |
| 1248 r"^native_client_sdk")) | 1248 r"^native_client_sdk")) |
| 1249 file_filter = lambda f: input_api.FilterSourceFile( | 1249 file_filter = lambda f: input_api.FilterSourceFile( |
| 1250 f, white_list=file_inclusion_pattern, black_list=black_list) | 1250 f, white_list=file_inclusion_pattern, black_list=black_list) |
| 1251 for fpath in input_api.AffectedFiles(file_filter=file_filter): | 1251 for fpath in input_api.AffectedFiles(file_filter=file_filter): |
| 1252 for line_num, line in fpath.ChangedContents(): | 1252 for line_num, line in fpath.ChangedContents(): |
| 1253 for (deprecated_value, value) in _DEPRECATED_CSS: | 1253 for (deprecated_value, value) in _DEPRECATED_CSS: |
| 1254 if input_api.re.search(deprecated_value, line): | 1254 if deprecated_value in line: |
| 1255 results.append(output_api.PresubmitError( | 1255 results.append(output_api.PresubmitError( |
| 1256 "%s:%d: Use of deprecated CSS %s, use %s instead" % | 1256 "%s:%d: Use of deprecated CSS %s, use %s instead" % |
| 1257 (fpath.LocalPath(), line_num, deprecated_value, value))) | 1257 (fpath.LocalPath(), line_num, deprecated_value, value))) |
| 1258 return results | 1258 return results |
| 1259 | 1259 |
| 1260 | 1260 |
| 1261 _DEPRECATED_JS = [ |
| 1262 ( "__lookupGetter__", "Object.getOwnPropertyDescriptor" ), |
| 1263 ( "__defineGetter__", "Object.defineProperty" ), |
| 1264 ( "__defineSetter__", "Object.defineProperty" ), |
| 1265 ] |
| 1266 |
| 1267 def _CheckNoDeprecatedJS(input_api, output_api): |
| 1268 """Make sure that we don't use deprecated JS in Chrome code.""" |
| 1269 results = [] |
| 1270 file_inclusion_pattern = (r".+\.js$",) # TODO(dbeam): .html? |
| 1271 black_list = (_EXCLUDED_PATHS + _TEST_CODE_EXCLUDED_PATHS + |
| 1272 input_api.DEFAULT_BLACK_LIST) |
| 1273 file_filter = lambda f: input_api.FilterSourceFile( |
| 1274 f, white_list=file_inclusion_pattern, black_list=black_list) |
| 1275 for fpath in input_api.AffectedFiles(file_filter=file_filter): |
| 1276 for lnum, line in fpath.ChangedContents(): |
| 1277 for (deprecated, replacement) in _DEPRECATED_JS: |
| 1278 if deprecated in line: |
| 1279 results.append(output_api.PresubmitError( |
| 1280 "%s:%d: Use of deprecated JS %s, use %s instead" % |
| 1281 (fpath.LocalPath(), lnum, deprecated, replacement))) |
| 1282 return results |
| 1283 |
| 1284 |
| 1261 def _CheckForOverrideAndFinalRules(input_api, output_api): | 1285 def _CheckForOverrideAndFinalRules(input_api, output_api): |
| 1262 """Checks for final and override used as per C++11""" | 1286 """Checks for final and override used as per C++11""" |
| 1263 problems = [] | 1287 problems = [] |
| 1264 for f in input_api.AffectedFiles(): | 1288 for f in input_api.AffectedFiles(): |
| 1265 if (f.LocalPath().endswith(('.cc', '.cpp', '.h', '.mm'))): | 1289 if (f.LocalPath().endswith(('.cc', '.cpp', '.h', '.mm'))): |
| 1266 for line_num, line in f.ChangedContents(): | 1290 for line_num, line in f.ChangedContents(): |
| 1267 if (input_api.re.search(r'\b(FINAL|OVERRIDE)\b', line)): | 1291 if (input_api.re.search(r'\b(FINAL|OVERRIDE)\b', line)): |
| 1268 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | 1292 problems.append(' %s:%d' % (f.LocalPath(), line_num)) |
| 1269 | 1293 |
| 1270 if not problems: | 1294 if not problems: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 results.extend( | 1330 results.extend( |
| 1307 input_api.canned_checks.CheckChangeHasNoTabs( | 1331 input_api.canned_checks.CheckChangeHasNoTabs( |
| 1308 input_api, | 1332 input_api, |
| 1309 output_api, | 1333 output_api, |
| 1310 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 1334 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) |
| 1311 results.extend(_CheckSpamLogging(input_api, output_api)) | 1335 results.extend(_CheckSpamLogging(input_api, output_api)) |
| 1312 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1336 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
| 1313 results.extend(_CheckCygwinShell(input_api, output_api)) | 1337 results.extend(_CheckCygwinShell(input_api, output_api)) |
| 1314 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1338 results.extend(_CheckUserActionUpdate(input_api, output_api)) |
| 1315 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 1339 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) |
| 1340 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) |
| 1316 results.extend(_CheckParseErrors(input_api, output_api)) | 1341 results.extend(_CheckParseErrors(input_api, output_api)) |
| 1317 results.extend(_CheckForIPCRules(input_api, output_api)) | 1342 results.extend(_CheckForIPCRules(input_api, output_api)) |
| 1318 results.extend(_CheckForOverrideAndFinalRules(input_api, output_api)) | 1343 results.extend(_CheckForOverrideAndFinalRules(input_api, output_api)) |
| 1319 | 1344 |
| 1320 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1345 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
| 1321 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1346 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 1322 input_api, output_api, | 1347 input_api, output_api, |
| 1323 input_api.PresubmitLocalPath(), | 1348 input_api.PresubmitLocalPath(), |
| 1324 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1349 whitelist=[r'^PRESUBMIT_test\.py$'])) |
| 1325 return results | 1350 return results |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 builders.extend(['cros_x86']) | 1757 builders.extend(['cros_x86']) |
| 1733 | 1758 |
| 1734 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1759 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it |
| 1735 # unless they're .gyp(i) files as changes to those files can break the gyp | 1760 # unless they're .gyp(i) files as changes to those files can break the gyp |
| 1736 # step on that bot. | 1761 # step on that bot. |
| 1737 if (not all(re.search('^chrome', f) for f in files) or | 1762 if (not all(re.search('^chrome', f) for f in files) or |
| 1738 any(re.search('\.gypi?$', f) for f in files)): | 1763 any(re.search('\.gypi?$', f) for f in files)): |
| 1739 builders.extend(['android_aosp']) | 1764 builders.extend(['android_aosp']) |
| 1740 | 1765 |
| 1741 return GetDefaultTryConfigs(builders) | 1766 return GetDefaultTryConfigs(builders) |
| OLD | NEW |