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 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 | 1510 |
1511 if files: | 1511 if files: |
1512 return [ output_api.PresubmitError( | 1512 return [ output_api.PresubmitError( |
1513 'Found base::Singleton<T> in the following header files.\n' + | 1513 'Found base::Singleton<T> in the following header files.\n' + |
1514 'Please move them to an appropriate source file so that the ' + | 1514 'Please move them to an appropriate source file so that the ' + |
1515 'template gets instantiated in a single compilation unit.', | 1515 'template gets instantiated in a single compilation unit.', |
1516 files) ] | 1516 files) ] |
1517 return [] | 1517 return [] |
1518 | 1518 |
1519 | 1519 |
| 1520 def _CheckBaseMacrosInHeaders(input_api, output_api): |
| 1521 """Check for base/macros.h if DISALLOW_* macro is used.""" |
| 1522 |
| 1523 disallows = ('DISALLOW_ASSIGN', 'DISALLOW_COPY', 'DISALLOW_EVIL') |
| 1524 macros = '#include "base/macros.h"' |
| 1525 basictypes = '#include "base/basictypes.h"' |
| 1526 |
| 1527 files = [] |
| 1528 for f in input_api.AffectedSourceFiles(None): |
| 1529 if not f.LocalPath().endswith('.h'): |
| 1530 continue |
| 1531 for line_num, line in f.ChangedContents(): |
| 1532 if any(d in line for d in disallows): |
| 1533 contents = input_api.ReadFile(f) |
| 1534 if not (macros in contents or basictypes in contents): |
| 1535 files.append(f) |
| 1536 break |
| 1537 |
| 1538 msg = ('The following files appear to be using DISALLOW_* macros.\n' |
| 1539 'Please #include "base/macros.h" in them.') |
| 1540 return [output_api.PresubmitError(msg, files)] if files else [] |
| 1541 |
| 1542 |
1520 _DEPRECATED_CSS = [ | 1543 _DEPRECATED_CSS = [ |
1521 # Values | 1544 # Values |
1522 ( "-webkit-box", "flex" ), | 1545 ( "-webkit-box", "flex" ), |
1523 ( "-webkit-inline-box", "inline-flex" ), | 1546 ( "-webkit-inline-box", "inline-flex" ), |
1524 ( "-webkit-flex", "flex" ), | 1547 ( "-webkit-flex", "flex" ), |
1525 ( "-webkit-inline-flex", "inline-flex" ), | 1548 ( "-webkit-inline-flex", "inline-flex" ), |
1526 ( "-webkit-min-content", "min-content" ), | 1549 ( "-webkit-min-content", "min-content" ), |
1527 ( "-webkit-max-content", "max-content" ), | 1550 ( "-webkit-max-content", "max-content" ), |
1528 | 1551 |
1529 # Properties | 1552 # Properties |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1662 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
1640 results.extend(_CheckCygwinShell(input_api, output_api)) | 1663 results.extend(_CheckCygwinShell(input_api, output_api)) |
1641 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1664 results.extend(_CheckUserActionUpdate(input_api, output_api)) |
1642 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 1665 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) |
1643 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) | 1666 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) |
1644 results.extend(_CheckParseErrors(input_api, output_api)) | 1667 results.extend(_CheckParseErrors(input_api, output_api)) |
1645 results.extend(_CheckForIPCRules(input_api, output_api)) | 1668 results.extend(_CheckForIPCRules(input_api, output_api)) |
1646 results.extend(_CheckForCopyrightedCode(input_api, output_api)) | 1669 results.extend(_CheckForCopyrightedCode(input_api, output_api)) |
1647 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) | 1670 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) |
1648 results.extend(_CheckSingletonInHeaders(input_api, output_api)) | 1671 results.extend(_CheckSingletonInHeaders(input_api, output_api)) |
| 1672 results.extend(_CheckBaseMacrosInHeaders(input_api, output_api)) |
1649 | 1673 |
1650 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1674 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
1651 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1675 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
1652 input_api, output_api, | 1676 input_api, output_api, |
1653 input_api.PresubmitLocalPath(), | 1677 input_api.PresubmitLocalPath(), |
1654 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1678 whitelist=[r'^PRESUBMIT_test\.py$'])) |
1655 return results | 1679 return results |
1656 | 1680 |
1657 | 1681 |
1658 def _CheckAuthorizedAuthor(input_api, output_api): | 1682 def _CheckAuthorizedAuthor(input_api, output_api): |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 for master in masters: | 1974 for master in masters: |
1951 try_config.setdefault(master, {}) | 1975 try_config.setdefault(master, {}) |
1952 for builder in masters[master]: | 1976 for builder in masters[master]: |
1953 # Do not trigger presubmit builders, since they're likely to fail | 1977 # Do not trigger presubmit builders, since they're likely to fail |
1954 # (e.g. OWNERS checks before finished code review), and we're | 1978 # (e.g. OWNERS checks before finished code review), and we're |
1955 # running local presubmit anyway. | 1979 # running local presubmit anyway. |
1956 if 'presubmit' not in builder: | 1980 if 'presubmit' not in builder: |
1957 try_config[master][builder] = ['defaulttests'] | 1981 try_config[master][builder] = ['defaulttests'] |
1958 | 1982 |
1959 return try_config | 1983 return try_config |
OLD | NEW |