diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 02:31:54 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 02:31:54 +0000 |
commit | 10689cad247866a32bf4d654d265700340f4a2a7 (patch) | |
tree | a388d0136f908e6ff541a4bc14067cf1c5b21f1d /PRESUBMIT.py | |
parent | 6fd550bdd8d9ad83330bed01efa25d801379e9f9 (diff) | |
download | chromium_src-10689cad247866a32bf4d654d265700340f4a2a7.zip chromium_src-10689cad247866a32bf4d654d265700340f4a2a7.tar.gz chromium_src-10689cad247866a32bf4d654d265700340f4a2a7.tar.bz2 |
Add a presubmit check that catches iostream usage in header files.
BUG=94794
TEST=none
Review URL: http://codereview.chromium.org/7792076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99291 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r-- | PRESUBMIT.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 63c81aa..1f51057 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -89,6 +89,27 @@ def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api): return [] +def _CheckNoIOStreamInHeaders(input_api, output_api): + """Checks to make sure no .h files include <iostream>.""" + files = [] + pattern = input_api.re.compile(r'^#include\s*<iostream>', + input_api.re.MULTILINE) + for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): + if not f.LocalPath().endswith('.h'): + continue + contents = input_api.ReadFile(f) + if pattern.search(contents): + files.append(f) + + if len(files): + return [ output_api.PresubmitError( + 'Do not #include <iostream> in header files, since it inserts static ' + + 'initialization into every file including the header. Instead, ' + + '#include <ostream>. See http://crbug.com/94794', + files) ] + return [] + + def _CommonChecks(input_api, output_api): """Checks common to both upload and commit.""" results = [] @@ -98,6 +119,7 @@ def _CommonChecks(input_api, output_api): results.extend(_CheckAuthorizedAuthor(input_api, output_api)) results.extend( _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) + results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) return results |