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 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1799 results.append(output_api.PresubmitError( | 1799 results.append(output_api.PresubmitError( |
1800 'File is stale: %s\nTo regenerate, run:\n\n %s' % | 1800 'File is stale: %s\nTo regenerate, run:\n\n %s' % |
1801 (pydep_path, cmd))) | 1801 (pydep_path, cmd))) |
1802 except input_api.subprocess.CalledProcessError as error: | 1802 except input_api.subprocess.CalledProcessError as error: |
1803 return [output_api.PresubmitError('Error running: %s' % error.cmd, | 1803 return [output_api.PresubmitError('Error running: %s' % error.cmd, |
1804 long_text=error.output)] | 1804 long_text=error.output)] |
1805 | 1805 |
1806 return results | 1806 return results |
1807 | 1807 |
1808 | 1808 |
1809 def _CheckForCopyrightedCode(input_api, output_api): | |
1810 """Verifies that newly added code doesn't contain copyrighted material | |
1811 and is properly licensed under the standard Chromium license. | |
1812 | |
1813 As there can be false positives, we maintain a whitelist file. This check | |
1814 also verifies that the whitelist file is up to date. | |
1815 """ | |
1816 import sys | |
1817 original_sys_path = sys.path | |
1818 try: | |
1819 sys.path = sys.path + [input_api.os_path.join( | |
1820 input_api.PresubmitLocalPath(), 'tools')] | |
1821 from copyright_scanner import copyright_scanner | |
1822 finally: | |
1823 # Restore sys.path to what it was before. | |
1824 sys.path = original_sys_path | |
1825 | |
1826 return copyright_scanner.ScanAtPresubmit(input_api, output_api) | |
1827 | |
1828 | |
1829 def _CheckSingletonInHeaders(input_api, output_api): | 1809 def _CheckSingletonInHeaders(input_api, output_api): |
1830 """Checks to make sure no header files have |Singleton<|.""" | 1810 """Checks to make sure no header files have |Singleton<|.""" |
1831 def FileFilter(affected_file): | 1811 def FileFilter(affected_file): |
1832 # It's ok for base/memory/singleton.h to have |Singleton<|. | 1812 # It's ok for base/memory/singleton.h to have |Singleton<|. |
1833 black_list = (_EXCLUDED_PATHS + | 1813 black_list = (_EXCLUDED_PATHS + |
1834 input_api.DEFAULT_BLACK_LIST + | 1814 input_api.DEFAULT_BLACK_LIST + |
1835 (r"^base[\\\/]memory[\\\/]singleton\.h$",)) | 1815 (r"^base[\\\/]memory[\\\/]singleton\.h$",)) |
1836 return input_api.FilterSourceFile(affected_file, black_list=black_list) | 1816 return input_api.FilterSourceFile(affected_file, black_list=black_list) |
1837 | 1817 |
1838 pattern = input_api.re.compile(r'(?<!class\sbase::)Singleton\s*<') | 1818 pattern = input_api.re.compile(r'(?<!class\sbase::)Singleton\s*<') |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 output_api, | 1977 output_api, |
1998 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 1978 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) |
1999 results.extend(_CheckSpamLogging(input_api, output_api)) | 1979 results.extend(_CheckSpamLogging(input_api, output_api)) |
2000 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1980 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
2001 results.extend(_CheckCygwinShell(input_api, output_api)) | 1981 results.extend(_CheckCygwinShell(input_api, output_api)) |
2002 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1982 results.extend(_CheckUserActionUpdate(input_api, output_api)) |
2003 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 1983 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) |
2004 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) | 1984 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) |
2005 results.extend(_CheckParseErrors(input_api, output_api)) | 1985 results.extend(_CheckParseErrors(input_api, output_api)) |
2006 results.extend(_CheckForIPCRules(input_api, output_api)) | 1986 results.extend(_CheckForIPCRules(input_api, output_api)) |
2007 results.extend(_CheckForCopyrightedCode(input_api, output_api)) | |
2008 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) | 1987 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) |
2009 results.extend(_CheckSingletonInHeaders(input_api, output_api)) | 1988 results.extend(_CheckSingletonInHeaders(input_api, output_api)) |
2010 results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) | 1989 results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) |
2011 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) | 1990 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) |
2012 results.extend(_CheckJavaStyle(input_api, output_api)) | 1991 results.extend(_CheckJavaStyle(input_api, output_api)) |
2013 results.extend(_CheckIpcOwners(input_api, output_api)) | 1992 results.extend(_CheckIpcOwners(input_api, output_api)) |
2014 results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api)) | 1993 results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api)) |
2015 | 1994 |
2016 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1995 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
2017 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1996 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2285 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 2264 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
2286 input_api, | 2265 input_api, |
2287 output_api, | 2266 output_api, |
2288 json_url='http://chromium-status.appspot.com/current?format=json')) | 2267 json_url='http://chromium-status.appspot.com/current?format=json')) |
2289 | 2268 |
2290 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2269 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
2291 input_api, output_api)) | 2270 input_api, output_api)) |
2292 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2271 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
2293 input_api, output_api)) | 2272 input_api, output_api)) |
2294 return results | 2273 return results |
OLD | NEW |