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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api)) | 1019 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api)) |
1020 results.extend( | 1020 results.extend( |
1021 input_api.canned_checks.CheckChangeHasNoTabs( | 1021 input_api.canned_checks.CheckChangeHasNoTabs( |
1022 input_api, | 1022 input_api, |
1023 output_api, | 1023 output_api, |
1024 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 1024 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) |
1025 results.extend(_CheckSpamLogging(input_api, output_api)) | 1025 results.extend(_CheckSpamLogging(input_api, output_api)) |
1026 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1026 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
1027 results.extend(_CheckCygwinShell(input_api, output_api)) | 1027 results.extend(_CheckCygwinShell(input_api, output_api)) |
1028 results.extend(_CheckJavaStyle(input_api, output_api)) | 1028 results.extend(_CheckJavaStyle(input_api, output_api)) |
| 1029 results.extend(_CheckForString16(input_api, output_api)) |
1029 | 1030 |
1030 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1031 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
1031 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1032 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
1032 input_api, output_api, | 1033 input_api, output_api, |
1033 input_api.PresubmitLocalPath(), | 1034 input_api.PresubmitLocalPath(), |
1034 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1035 whitelist=[r'^PRESUBMIT_test\.py$'])) |
1035 return results | 1036 return results |
1036 | 1037 |
1037 | 1038 |
1038 def _CheckSubversionConfig(input_api, output_api): | 1039 def _CheckSubversionConfig(input_api, output_api): |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 bad_macros.extend(_CheckForInvalidOSMacrosInFile(input_api, f)) | 1162 bad_macros.extend(_CheckForInvalidOSMacrosInFile(input_api, f)) |
1162 | 1163 |
1163 if not bad_macros: | 1164 if not bad_macros: |
1164 return [] | 1165 return [] |
1165 | 1166 |
1166 return [output_api.PresubmitError( | 1167 return [output_api.PresubmitError( |
1167 'Possibly invalid OS macro[s] found. Please fix your code\n' | 1168 'Possibly invalid OS macro[s] found. Please fix your code\n' |
1168 'or add your macro to src/PRESUBMIT.py.', bad_macros)] | 1169 'or add your macro to src/PRESUBMIT.py.', bad_macros)] |
1169 | 1170 |
1170 | 1171 |
| 1172 def _CheckForString16InFile(input_api, f): |
| 1173 """Check for string16 without base:: in front.""" |
| 1174 reg = input_api.re.compile(r'\b(?<!base::)string16\b') |
| 1175 use = 'using base::string16;' |
| 1176 include = '#include "base/strings/string16.h"' |
| 1177 results = [] |
| 1178 for lnum, line in f.ChangedContents(): |
| 1179 if reg.search(line) and not include in line and not use in f.NewContents(): |
| 1180 results.append(' %s:%d' % (f.LocalPath(), lnum)) |
| 1181 return results |
| 1182 |
| 1183 |
| 1184 def _CheckForString16(input_api, output_api): |
| 1185 file_filter = lambda f: input_api.FilterSourceFile(f, |
| 1186 white_list=(r'^chrome[\\\/]browser[\\\/]', ), |
| 1187 black_list=(_EXCLUDED_PATHS + _TEST_CODE_EXCLUDED_PATHS + |
| 1188 input_api.DEFAULT_BLACK_LIST)) |
| 1189 |
| 1190 unprefixed = [] |
| 1191 for f in input_api.AffectedFiles(file_filter=file_filter): |
| 1192 unprefixed.extend(_CheckForString16InFile(input_api, f)) |
| 1193 |
| 1194 if not unprefixed: |
| 1195 return [] |
| 1196 |
| 1197 return [output_api.PresubmitPromptWarning( |
| 1198 'string16 should be prefixed with base:: namespace.', unprefixed)] |
| 1199 |
| 1200 |
1171 def CheckChangeOnUpload(input_api, output_api): | 1201 def CheckChangeOnUpload(input_api, output_api): |
1172 results = [] | 1202 results = [] |
1173 results.extend(_CommonChecks(input_api, output_api)) | 1203 results.extend(_CommonChecks(input_api, output_api)) |
1174 return results | 1204 return results |
1175 | 1205 |
1176 | 1206 |
1177 def CheckChangeOnCommit(input_api, output_api): | 1207 def CheckChangeOnCommit(input_api, output_api): |
1178 results = [] | 1208 results = [] |
1179 results.extend(_CommonChecks(input_api, output_api)) | 1209 results.extend(_CommonChecks(input_api, output_api)) |
1180 # TODO(thestig) temporarily disabled, doesn't work in third_party/ | 1210 # TODO(thestig) temporarily disabled, doesn't work in third_party/ |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 trybots += ['cros_x86'] | 1276 trybots += ['cros_x86'] |
1247 | 1277 |
1248 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1278 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it |
1249 # unless they're .gyp(i) files as changes to those files can break the gyp | 1279 # unless they're .gyp(i) files as changes to those files can break the gyp |
1250 # step on that bot. | 1280 # step on that bot. |
1251 if (not all(re.search('^chrome', f) for f in files) or | 1281 if (not all(re.search('^chrome', f) for f in files) or |
1252 any(re.search('\.gypi?$', f) for f in files)): | 1282 any(re.search('\.gypi?$', f) for f in files)): |
1253 trybots += ['android_aosp'] | 1283 trybots += ['android_aosp'] |
1254 | 1284 |
1255 return trybots | 1285 return trybots |
OLD | NEW |