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 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1937 | 1937 |
1938 | 1938 |
1939 def _AndroidSpecificOnUploadChecks(input_api, output_api): | 1939 def _AndroidSpecificOnUploadChecks(input_api, output_api): |
1940 """Groups checks that target android code.""" | 1940 """Groups checks that target android code.""" |
1941 results = [] | 1941 results = [] |
1942 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) | 1942 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) |
1943 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) | 1943 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) |
1944 results.extend(_CheckAndroidToastUsage(input_api, output_api)) | 1944 results.extend(_CheckAndroidToastUsage(input_api, output_api)) |
1945 return results | 1945 return results |
1946 | 1946 |
1947 def _CheckNewSourceFileAddedToGn(input_api, output_api): | |
1948 """Checks new source code files were added to GN files""" | |
1949 new_source_files = [] | |
1950 gn_files = [] | |
1951 | |
1952 """ Get lists of new source code files and GN files in the commit""" | |
1953 for f in input_api.AffectedFiles(): | |
1954 if f.LocalPath().endswith('.gn'): | |
1955 gn_files.append(f) | |
1956 continue | |
1957 if f.LocalPath().endswith(('.h', '.c', '.cc', '.m', '.mm', '.java')): | |
1958 for line in f.GenerateScmDiff().splitlines(): | |
1959 if line.startswith('@@ -0,0'): | |
Dirk Pranke
2016/08/19 20:42:02
You don't need to look at the diff.
f.Action() r
maksims (do not use this acc)
2016/08/23 06:00:18
Done.
| |
1960 new_source_files.append(f.LocalPath()) | |
1961 break | |
1962 | |
1963 if not new_source_files: | |
1964 return [] | |
1965 | |
1966 if not gn_files: | |
Dirk Pranke
2016/08/19 20:42:02
Eventually something like this'll be the right che
maksims (do not use this acc)
2016/08/23 06:00:18
Done.
| |
1967 return [output_api.PresubmitPromptWarning('The following new' | |
1968 ' source code files must be added to GN files:\n ' + | |
1969 '\n '.join(new_source_files))] | |
1970 | |
1971 """Get a list of new source code files that CAN BE FOUND in the GN files""" | |
1972 source_files_listed = [] | |
1973 for ff in new_source_files: | |
1974 head, sep, tail = ff.partition('/') | |
1975 if tail: | |
1976 source_file_match_pattern = tail + '",' | |
1977 else: | |
1978 source_file_match_pattern = ff + '",' | |
1979 for gn in gn_files: | |
1980 for line in gn.GenerateScmDiff().splitlines(): | |
1981 if line.endswith(source_file_match_pattern): | |
1982 source_files_listed.append(ff) | |
1983 break | |
1984 | |
1985 """Remove files, which has been found in the GN files, from the list""" | |
1986 for f in source_files_listed: | |
1987 if f in new_source_files: | |
1988 new_source_files.remove(f) | |
1989 | |
1990 return [output_api.PresubmitPromptWarning('The following new' | |
1991 ' source code files must be added to GN files:\n ' + | |
1992 '\n '.join(new_source_files))] | |
1947 | 1993 |
1948 def _CommonChecks(input_api, output_api): | 1994 def _CommonChecks(input_api, output_api): |
1949 """Checks common to both upload and commit.""" | 1995 """Checks common to both upload and commit.""" |
1950 results = [] | 1996 results = [] |
1951 results.extend(input_api.canned_checks.PanProjectChecks( | 1997 results.extend(input_api.canned_checks.PanProjectChecks( |
1952 input_api, output_api, | 1998 input_api, output_api, |
1953 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) | 1999 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) |
1954 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 2000 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) |
1955 results.extend( | 2001 results.extend( |
1956 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 2002 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1988 results.extend(_CheckParseErrors(input_api, output_api)) | 2034 results.extend(_CheckParseErrors(input_api, output_api)) |
1989 results.extend(_CheckForIPCRules(input_api, output_api)) | 2035 results.extend(_CheckForIPCRules(input_api, output_api)) |
1990 results.extend(_CheckForCopyrightedCode(input_api, output_api)) | 2036 results.extend(_CheckForCopyrightedCode(input_api, output_api)) |
1991 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) | 2037 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) |
1992 results.extend(_CheckSingletonInHeaders(input_api, output_api)) | 2038 results.extend(_CheckSingletonInHeaders(input_api, output_api)) |
1993 results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) | 2039 results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) |
1994 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) | 2040 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) |
1995 results.extend(_CheckJavaStyle(input_api, output_api)) | 2041 results.extend(_CheckJavaStyle(input_api, output_api)) |
1996 results.extend(_CheckIpcOwners(input_api, output_api)) | 2042 results.extend(_CheckIpcOwners(input_api, output_api)) |
1997 results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api)) | 2043 results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api)) |
2044 results.extend(_CheckNewSourceFileAddedToGn(input_api, output_api)) | |
1998 | 2045 |
1999 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 2046 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
2000 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 2047 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
2001 input_api, output_api, | 2048 input_api, output_api, |
2002 input_api.PresubmitLocalPath(), | 2049 input_api.PresubmitLocalPath(), |
2003 whitelist=[r'^PRESUBMIT_test\.py$'])) | 2050 whitelist=[r'^PRESUBMIT_test\.py$'])) |
2004 return results | 2051 return results |
2005 | 2052 |
2006 | 2053 |
2007 def _CheckAuthorizedAuthor(input_api, output_api): | 2054 def _CheckAuthorizedAuthor(input_api, output_api): |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2253 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 2300 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
2254 input_api, | 2301 input_api, |
2255 output_api, | 2302 output_api, |
2256 json_url='http://chromium-status.appspot.com/current?format=json')) | 2303 json_url='http://chromium-status.appspot.com/current?format=json')) |
2257 | 2304 |
2258 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2305 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
2259 input_api, output_api)) | 2306 input_api, output_api)) |
2260 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2307 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
2261 input_api, output_api)) | 2308 input_api, output_api)) |
2262 return results | 2309 return results |
OLD | NEW |