| 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 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 | 1939 |
| 1940 | 1940 |
| 1941 def _AndroidSpecificOnUploadChecks(input_api, output_api): | 1941 def _AndroidSpecificOnUploadChecks(input_api, output_api): |
| 1942 """Groups checks that target android code.""" | 1942 """Groups checks that target android code.""" |
| 1943 results = [] | 1943 results = [] |
| 1944 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) | 1944 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) |
| 1945 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) | 1945 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) |
| 1946 results.extend(_CheckAndroidToastUsage(input_api, output_api)) | 1946 results.extend(_CheckAndroidToastUsage(input_api, output_api)) |
| 1947 return results | 1947 return results |
| 1948 | 1948 |
| 1949 def _CheckNewSourceFileAddedToGnGypi(input_api, output_api): | |
| 1950 """Checks new source code files were added to GN/GYPi files""" | |
| 1951 new_source_files = [] | |
| 1952 gn_gypi_files = [] | |
| 1953 | |
| 1954 """ Get lists of new source code files and GN/GYPi files in the commit""" | |
| 1955 for f in input_api.AffectedFiles(): | |
| 1956 if f.LocalPath().endswith(('.gn', '.gypi')): | |
| 1957 gn_gypi_files.append(f) | |
| 1958 continue | |
| 1959 if f.LocalPath().endswith(('.h', '.c', '.cc', '.m', '.mm', '.java')): | |
| 1960 if f.Action() == 'A': | |
| 1961 new_source_files.append(f.LocalPath()) | |
| 1962 | |
| 1963 if not new_source_files: | |
| 1964 return [] | |
| 1965 | |
| 1966 if not gn_gypi_files: | |
| 1967 return [output_api.PresubmitPromptWarning('The following new' | |
| 1968 ' source code files must be added to GN/GYPI 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/GYPI | |
| 1972 files""" | |
| 1973 source_files_listed = [] | |
| 1974 for f in new_source_files: | |
| 1975 head, sep, tail = f.rpartition('/') | |
| 1976 source_file_match_pattern = tail | |
| 1977 for g in gn_gypi_files: | |
| 1978 for line in g.GenerateScmDiff().splitlines(): | |
| 1979 if line.endswith((source_file_match_pattern + '",', | |
| 1980 source_file_match_pattern + '\',')): | |
| 1981 source_files_listed.append(f) | |
| 1982 break | |
| 1983 | |
| 1984 """Remove files, which has been found in the GN files, from the list""" | |
| 1985 for f in source_files_listed: | |
| 1986 if f in new_source_files: | |
| 1987 new_source_files.remove(f) | |
| 1988 | |
| 1989 if new_source_files: | |
| 1990 return [output_api.PresubmitPromptWarning('The following new' | |
| 1991 ' source code files must be added to GN/GYPI files:\n ' + | |
| 1992 '\n '.join(new_source_files))] | |
| 1993 | |
| 1994 return [] | |
| 1995 | 1949 |
| 1996 def _CommonChecks(input_api, output_api): | 1950 def _CommonChecks(input_api, output_api): |
| 1997 """Checks common to both upload and commit.""" | 1951 """Checks common to both upload and commit.""" |
| 1998 results = [] | 1952 results = [] |
| 1999 results.extend(input_api.canned_checks.PanProjectChecks( | 1953 results.extend(input_api.canned_checks.PanProjectChecks( |
| 2000 input_api, output_api, | 1954 input_api, output_api, |
| 2001 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) | 1955 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) |
| 2002 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 1956 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) |
| 2003 results.extend( | 1957 results.extend( |
| 2004 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 1958 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 results.extend(_CheckParseErrors(input_api, output_api)) | 1990 results.extend(_CheckParseErrors(input_api, output_api)) |
| 2037 results.extend(_CheckForIPCRules(input_api, output_api)) | 1991 results.extend(_CheckForIPCRules(input_api, output_api)) |
| 2038 results.extend(_CheckForCopyrightedCode(input_api, output_api)) | 1992 results.extend(_CheckForCopyrightedCode(input_api, output_api)) |
| 2039 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) | 1993 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) |
| 2040 results.extend(_CheckSingletonInHeaders(input_api, output_api)) | 1994 results.extend(_CheckSingletonInHeaders(input_api, output_api)) |
| 2041 results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) | 1995 results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) |
| 2042 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) | 1996 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) |
| 2043 results.extend(_CheckJavaStyle(input_api, output_api)) | 1997 results.extend(_CheckJavaStyle(input_api, output_api)) |
| 2044 results.extend(_CheckIpcOwners(input_api, output_api)) | 1998 results.extend(_CheckIpcOwners(input_api, output_api)) |
| 2045 results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api)) | 1999 results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api)) |
| 2046 results.extend(_CheckNewSourceFileAddedToGnGypi(input_api, output_api)) | |
| 2047 | 2000 |
| 2048 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 2001 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
| 2049 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 2002 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 2050 input_api, output_api, | 2003 input_api, output_api, |
| 2051 input_api.PresubmitLocalPath(), | 2004 input_api.PresubmitLocalPath(), |
| 2052 whitelist=[r'^PRESUBMIT_test\.py$'])) | 2005 whitelist=[r'^PRESUBMIT_test\.py$'])) |
| 2053 return results | 2006 return results |
| 2054 | 2007 |
| 2055 | 2008 |
| 2056 def _CheckAuthorizedAuthor(input_api, output_api): | 2009 def _CheckAuthorizedAuthor(input_api, output_api): |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 2255 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
| 2303 input_api, | 2256 input_api, |
| 2304 output_api, | 2257 output_api, |
| 2305 json_url='http://chromium-status.appspot.com/current?format=json')) | 2258 json_url='http://chromium-status.appspot.com/current?format=json')) |
| 2306 | 2259 |
| 2307 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2260 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
| 2308 input_api, output_api)) | 2261 input_api, output_api)) |
| 2309 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2262 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
| 2310 input_api, output_api)) | 2263 input_api, output_api)) |
| 2311 return results | 2264 return results |
| OLD | NEW |