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 |
| 11 | 11 |
| 12 import json | |
|
M-A Ruel
2014/04/24 00:32:50
not needed
| |
| 12 import re | 13 import re |
| 13 import sys | 14 import sys |
| 14 | 15 |
| 15 | 16 |
| 16 _EXCLUDED_PATHS = ( | 17 _EXCLUDED_PATHS = ( |
| 17 r"^breakpad[\\\/].*", | 18 r"^breakpad[\\\/].*", |
| 18 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py", | 19 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py", |
| 19 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py", | 20 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py", |
| 20 r"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk", | 21 r"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk", |
| 21 r"^net[\\\/]tools[\\\/]spdyshark[\\\/].*", | 22 r"^net[\\\/]tools[\\\/]spdyshark[\\\/].*", |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1055 action = 'name="{0}"'.format(action_name) | 1056 action = 'name="{0}"'.format(action_name) |
| 1056 if action not in current_actions: | 1057 if action not in current_actions: |
| 1057 return [output_api.PresubmitPromptWarning( | 1058 return [output_api.PresubmitPromptWarning( |
| 1058 'File %s line %d: %s is missing in ' | 1059 'File %s line %d: %s is missing in ' |
| 1059 'tools/metrics/actions/actions.xml. Please run ' | 1060 'tools/metrics/actions/actions.xml. Please run ' |
| 1060 'tools/metrics/actions/extract_actions.py to update.' | 1061 'tools/metrics/actions/extract_actions.py to update.' |
| 1061 % (f.LocalPath(), line_num, action_name))] | 1062 % (f.LocalPath(), line_num, action_name))] |
| 1062 return [] | 1063 return [] |
| 1063 | 1064 |
| 1064 | 1065 |
| 1066 def _CheckJSONParsability(input_api, output_api): | |
| 1067 results = [] | |
| 1068 file_filter = lambda f: f.LocalPath().endswith('.json') | |
| 1069 for fpath in input_api.AffectedFiles(file_filter= file_filter): | |
|
M-A Ruel
2014/04/24 00:32:50
remove space
iannucci
2014/04/24 00:36:20
Oops, Done.
| |
| 1070 with open(fpath.LocalPath(), 'r') as f: | |
| 1071 try: | |
| 1072 json.load(f) | |
|
M-A Ruel
2014/04/24 00:32:50
input_api.json.load(f)
iannucci
2014/04/24 00:36:20
Done.
| |
| 1073 except ValueError: | |
| 1074 results.append(output_api.PresubmitError( | |
| 1075 "File %r does not parse as valid JSON" % (fpath.LocalPath()) | |
| 1076 )) | |
| 1077 return results | |
| 1078 | |
| 1079 | |
| 1065 def _CheckJavaStyle(input_api, output_api): | 1080 def _CheckJavaStyle(input_api, output_api): |
| 1066 """Runs checkstyle on changed java files and returns errors if any exist.""" | 1081 """Runs checkstyle on changed java files and returns errors if any exist.""" |
| 1067 original_sys_path = sys.path | 1082 original_sys_path = sys.path |
| 1068 try: | 1083 try: |
| 1069 sys.path = sys.path + [input_api.os_path.join( | 1084 sys.path = sys.path + [input_api.os_path.join( |
| 1070 input_api.PresubmitLocalPath(), 'tools', 'android', 'checkstyle')] | 1085 input_api.PresubmitLocalPath(), 'tools', 'android', 'checkstyle')] |
| 1071 import checkstyle | 1086 import checkstyle |
| 1072 finally: | 1087 finally: |
| 1073 # Restore sys.path to what it was before. | 1088 # Restore sys.path to what it was before. |
| 1074 sys.path = original_sys_path | 1089 sys.path = original_sys_path |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1105 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api)) | 1120 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api)) |
| 1106 results.extend( | 1121 results.extend( |
| 1107 input_api.canned_checks.CheckChangeHasNoTabs( | 1122 input_api.canned_checks.CheckChangeHasNoTabs( |
| 1108 input_api, | 1123 input_api, |
| 1109 output_api, | 1124 output_api, |
| 1110 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 1125 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) |
| 1111 results.extend(_CheckSpamLogging(input_api, output_api)) | 1126 results.extend(_CheckSpamLogging(input_api, output_api)) |
| 1112 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1127 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
| 1113 results.extend(_CheckCygwinShell(input_api, output_api)) | 1128 results.extend(_CheckCygwinShell(input_api, output_api)) |
| 1114 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1129 results.extend(_CheckUserActionUpdate(input_api, output_api)) |
| 1130 results.extend(_CheckJSONParsability(input_api, output_api)) | |
| 1115 | 1131 |
| 1116 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1132 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
| 1117 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1133 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 1118 input_api, output_api, | 1134 input_api, output_api, |
| 1119 input_api.PresubmitLocalPath(), | 1135 input_api.PresubmitLocalPath(), |
| 1120 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1136 whitelist=[r'^PRESUBMIT_test\.py$'])) |
| 1121 return results | 1137 return results |
| 1122 | 1138 |
| 1123 | 1139 |
| 1124 def _CheckSubversionConfig(input_api, output_api): | 1140 def _CheckSubversionConfig(input_api, output_api): |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1494 builders.extend(['cros_x86']) | 1510 builders.extend(['cros_x86']) |
| 1495 | 1511 |
| 1496 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1512 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it |
| 1497 # unless they're .gyp(i) files as changes to those files can break the gyp | 1513 # unless they're .gyp(i) files as changes to those files can break the gyp |
| 1498 # step on that bot. | 1514 # step on that bot. |
| 1499 if (not all(re.search('^chrome', f) for f in files) or | 1515 if (not all(re.search('^chrome', f) for f in files) or |
| 1500 any(re.search('\.gypi?$', f) for f in files)): | 1516 any(re.search('\.gypi?$', f) for f in files)): |
| 1501 builders.extend(['android_aosp']) | 1517 builders.extend(['android_aosp']) |
| 1502 | 1518 |
| 1503 return GetDefaultTryConfigs(builders) | 1519 return GetDefaultTryConfigs(builders) |
| OLD | NEW |