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 depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
9 """ | 9 """ |
10 | 10 |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 output = output_api.PresubmitError | 1544 output = output_api.PresubmitError |
1545 else: | 1545 else: |
1546 output = output_api.PresubmitPromptWarning | 1546 output = output_api.PresubmitPromptWarning |
1547 results.append(output( | 1547 results.append(output( |
1548 'Found changes to IPC files without a security OWNER!', | 1548 'Found changes to IPC files without a security OWNER!', |
1549 long_text='\n\n'.join(errors))) | 1549 long_text='\n\n'.join(errors))) |
1550 | 1550 |
1551 return results | 1551 return results |
1552 | 1552 |
1553 | 1553 |
1554 def _CheckMojoUsesNewWrapperTypes(input_api, output_api): | |
1555 """Checks to make sure that all newly added mojom targets map array/map/string | |
1556 to STL (for chromium) or WTF (for blink) types. | |
1557 TODO(yzshen): remove this check once crbug.com/624136 is completed. | |
1558 """ | |
1559 files = [] | |
1560 pattern = input_api.re.compile(r'use_new_wrapper_types.*false', | |
1561 input_api.re.MULTILINE) | |
1562 | |
1563 for f in input_api.AffectedFiles(): | |
1564 if not f.LocalPath().endswith(('.gyp', '.gypi', 'gn', 'gni')): | |
1565 continue | |
1566 | |
1567 for _, line in f.ChangedContents(): | |
1568 if pattern.search(line): | |
1569 files.append(f) | |
1570 break | |
1571 | |
1572 if len(files): | |
1573 return [output_api.PresubmitError( | |
1574 'Do not introduce new mojom targets with use_new_wrapper_types set to ' | |
1575 'false. The mode is deprecated and will be removed soon.', | |
1576 files)] | |
1577 return [] | |
1578 | |
1579 | |
1580 def _CheckUselessForwardDeclarations(input_api, output_api): | 1554 def _CheckUselessForwardDeclarations(input_api, output_api): |
1581 """Checks that added or removed lines in non third party affected | 1555 """Checks that added or removed lines in non third party affected |
1582 header files do not lead to new useless class or struct forward | 1556 header files do not lead to new useless class or struct forward |
1583 declaration. | 1557 declaration. |
1584 """ | 1558 """ |
1585 results = [] | 1559 results = [] |
1586 class_pattern = input_api.re.compile(r'^class\s+(\w+);$', | 1560 class_pattern = input_api.re.compile(r'^class\s+(\w+);$', |
1587 input_api.re.MULTILINE) | 1561 input_api.re.MULTILINE) |
1588 struct_pattern = input_api.re.compile(r'^struct\s+(\w+);$', | 1562 struct_pattern = input_api.re.compile(r'^struct\s+(\w+);$', |
1589 input_api.re.MULTILINE) | 1563 input_api.re.MULTILINE) |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 results.extend(_CheckNoDeprecatedCss(input_api, output_api)) | 2060 results.extend(_CheckNoDeprecatedCss(input_api, output_api)) |
2087 results.extend(_CheckNoDeprecatedJs(input_api, output_api)) | 2061 results.extend(_CheckNoDeprecatedJs(input_api, output_api)) |
2088 results.extend(_CheckParseErrors(input_api, output_api)) | 2062 results.extend(_CheckParseErrors(input_api, output_api)) |
2089 results.extend(_CheckForIPCRules(input_api, output_api)) | 2063 results.extend(_CheckForIPCRules(input_api, output_api)) |
2090 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) | 2064 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) |
2091 results.extend(_CheckSingletonInHeaders(input_api, output_api)) | 2065 results.extend(_CheckSingletonInHeaders(input_api, output_api)) |
2092 results.extend(_CheckNoDeprecatedCompiledResourcesGyp(input_api, output_api)) | 2066 results.extend(_CheckNoDeprecatedCompiledResourcesGyp(input_api, output_api)) |
2093 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) | 2067 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) |
2094 results.extend(_CheckJavaStyle(input_api, output_api)) | 2068 results.extend(_CheckJavaStyle(input_api, output_api)) |
2095 results.extend(_CheckIpcOwners(input_api, output_api)) | 2069 results.extend(_CheckIpcOwners(input_api, output_api)) |
2096 results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api)) | |
2097 results.extend(_CheckUselessForwardDeclarations(input_api, output_api)) | 2070 results.extend(_CheckUselessForwardDeclarations(input_api, output_api)) |
2098 results.extend(_CheckForRiskyJsFeatures(input_api, output_api)) | 2071 results.extend(_CheckForRiskyJsFeatures(input_api, output_api)) |
2099 | 2072 |
2100 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 2073 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
2101 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 2074 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
2102 input_api, output_api, | 2075 input_api, output_api, |
2103 input_api.PresubmitLocalPath(), | 2076 input_api.PresubmitLocalPath(), |
2104 whitelist=[r'^PRESUBMIT_test\.py$'])) | 2077 whitelist=[r'^PRESUBMIT_test\.py$'])) |
2105 return results | 2078 return results |
2106 | 2079 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2342 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 2315 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
2343 input_api, | 2316 input_api, |
2344 output_api, | 2317 output_api, |
2345 json_url='http://chromium-status.appspot.com/current?format=json')) | 2318 json_url='http://chromium-status.appspot.com/current?format=json')) |
2346 | 2319 |
2347 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2320 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
2348 input_api, output_api)) | 2321 input_api, output_api)) |
2349 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2322 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
2350 input_api, output_api)) | 2323 input_api, output_api)) |
2351 return results | 2324 return results |
OLD | NEW |