| 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 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 | 1530 |
| 1531 if files: | 1531 if files: |
| 1532 return [ output_api.PresubmitError( | 1532 return [ output_api.PresubmitError( |
| 1533 'Found base::Singleton<T> in the following header files.\n' + | 1533 'Found base::Singleton<T> in the following header files.\n' + |
| 1534 'Please move them to an appropriate source file so that the ' + | 1534 'Please move them to an appropriate source file so that the ' + |
| 1535 'template gets instantiated in a single compilation unit.', | 1535 'template gets instantiated in a single compilation unit.', |
| 1536 files) ] | 1536 files) ] |
| 1537 return [] | 1537 return [] |
| 1538 | 1538 |
| 1539 | 1539 |
| 1540 def _CheckBaseMacrosInHeaders(input_api, output_api): | |
| 1541 """Check for base/macros.h if DISALLOW_* macro is used.""" | |
| 1542 | |
| 1543 disallows = ('DISALLOW_ASSIGN', 'DISALLOW_COPY', 'DISALLOW_EVIL') | |
| 1544 macros = '#include "base/macros.h"' | |
| 1545 basictypes = '#include "base/basictypes.h"' | |
| 1546 | |
| 1547 files = [] | |
| 1548 for f in input_api.AffectedSourceFiles(None): | |
| 1549 if not f.LocalPath().endswith('.h'): | |
| 1550 continue | |
| 1551 for line_num, line in f.ChangedContents(): | |
| 1552 if line.lstrip().startswith('//'): # Strip C++ comment. | |
| 1553 continue | |
| 1554 if any(d in line for d in disallows): | |
| 1555 contents = input_api.ReadFile(f) | |
| 1556 if not (macros in contents or basictypes in contents): | |
| 1557 files.append(f) | |
| 1558 break | |
| 1559 | |
| 1560 msg = ('The following files appear to be using DISALLOW_* macros.\n' | |
| 1561 'Please #include "base/macros.h" in them.') | |
| 1562 return [output_api.PresubmitError(msg, files)] if files else [] | |
| 1563 | |
| 1564 | |
| 1565 _DEPRECATED_CSS = [ | 1540 _DEPRECATED_CSS = [ |
| 1566 # Values | 1541 # Values |
| 1567 ( "-webkit-box", "flex" ), | 1542 ( "-webkit-box", "flex" ), |
| 1568 ( "-webkit-inline-box", "inline-flex" ), | 1543 ( "-webkit-inline-box", "inline-flex" ), |
| 1569 ( "-webkit-flex", "flex" ), | 1544 ( "-webkit-flex", "flex" ), |
| 1570 ( "-webkit-inline-flex", "inline-flex" ), | 1545 ( "-webkit-inline-flex", "inline-flex" ), |
| 1571 ( "-webkit-min-content", "min-content" ), | 1546 ( "-webkit-min-content", "min-content" ), |
| 1572 ( "-webkit-max-content", "max-content" ), | 1547 ( "-webkit-max-content", "max-content" ), |
| 1573 | 1548 |
| 1574 # Properties | 1549 # Properties |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1660 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
| 1686 results.extend(_CheckCygwinShell(input_api, output_api)) | 1661 results.extend(_CheckCygwinShell(input_api, output_api)) |
| 1687 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1662 results.extend(_CheckUserActionUpdate(input_api, output_api)) |
| 1688 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 1663 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) |
| 1689 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) | 1664 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) |
| 1690 results.extend(_CheckParseErrors(input_api, output_api)) | 1665 results.extend(_CheckParseErrors(input_api, output_api)) |
| 1691 results.extend(_CheckForIPCRules(input_api, output_api)) | 1666 results.extend(_CheckForIPCRules(input_api, output_api)) |
| 1692 results.extend(_CheckForCopyrightedCode(input_api, output_api)) | 1667 results.extend(_CheckForCopyrightedCode(input_api, output_api)) |
| 1693 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) | 1668 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) |
| 1694 results.extend(_CheckSingletonInHeaders(input_api, output_api)) | 1669 results.extend(_CheckSingletonInHeaders(input_api, output_api)) |
| 1695 results.extend(_CheckBaseMacrosInHeaders(input_api, output_api)) | |
| 1696 | 1670 |
| 1697 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1671 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
| 1698 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1672 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 1699 input_api, output_api, | 1673 input_api, output_api, |
| 1700 input_api.PresubmitLocalPath(), | 1674 input_api.PresubmitLocalPath(), |
| 1701 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1675 whitelist=[r'^PRESUBMIT_test\.py$'])) |
| 1702 return results | 1676 return results |
| 1703 | 1677 |
| 1704 | 1678 |
| 1705 def _CheckAuthorizedAuthor(input_api, output_api): | 1679 def _CheckAuthorizedAuthor(input_api, output_api): |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1994 for master in masters: | 1968 for master in masters: |
| 1995 try_config.setdefault(master, {}) | 1969 try_config.setdefault(master, {}) |
| 1996 for builder in masters[master]: | 1970 for builder in masters[master]: |
| 1997 # Do not trigger presubmit builders, since they're likely to fail | 1971 # Do not trigger presubmit builders, since they're likely to fail |
| 1998 # (e.g. OWNERS checks before finished code review), and we're | 1972 # (e.g. OWNERS checks before finished code review), and we're |
| 1999 # running local presubmit anyway. | 1973 # running local presubmit anyway. |
| 2000 if 'presubmit' not in builder: | 1974 if 'presubmit' not in builder: |
| 2001 try_config[master][builder] = ['defaulttests'] | 1975 try_config[master][builder] = ['defaulttests'] |
| 2002 | 1976 |
| 2003 return try_config | 1977 return try_config |
| OLD | NEW |