Chromium Code Reviews| Index: PRESUBMIT.py |
| diff --git a/PRESUBMIT.py b/PRESUBMIT.py |
| index 27f03a9ffb0b5303734eedf3a6450d0d399e658e..ecd2c79ebf4060a664d04131c790eed9978e5935 100644 |
| --- a/PRESUBMIT.py |
| +++ b/PRESUBMIT.py |
| @@ -8,6 +8,7 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| for more details about the presubmit API built into gcl. |
| """ |
| + |
| _EXCLUDED_PATHS = ( |
| r"^breakpad[\\\/].*", |
| r"^net/tools/spdyshark/[\\\/].*", |
| @@ -17,6 +18,15 @@ _EXCLUDED_PATHS = ( |
| ) |
| +_TEST_ONLY_WARNING = ( |
| + 'You might be calling functions intended only for testing from\n' |
| + 'production code. It is OK to ignore this warning if you know what\n' |
| + 'you are doing, as the heuristics used to detect the situation are\n' |
| + 'not perfect. The commit queue will not block on this warning.\n' |
| + 'Email joi@chromium.org if you have questions.') |
| + |
| + |
| + |
| def _CheckNoInterfacesInBase(input_api, output_api): |
| """Checks to make sure no files in libbase.a have |@interface|.""" |
| pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE) |
| @@ -37,7 +47,8 @@ def _CheckNoInterfacesInBase(input_api, output_api): |
| return [] |
| -def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api): |
| +def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, |
|
M-A Ruel
2011/11/18 11:26:49
Not necessary. :)
|
| + output_api): |
| """Attempts to prevent use of functions intended only for testing in |
| non-testing code. For now this is just a best-effort implementation |
| that ignores header files and may have some false positives. A |
| @@ -87,11 +98,11 @@ def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api): |
| line_number += 1 |
| if problems: |
| - return [output_api.PresubmitPromptWarning( |
| - 'You might be calling functions intended only for testing from\n' |
| - 'production code. Please verify that the following usages are OK,\n' |
| - 'and email joi@chromium.org if you are seeing false positives:', |
| - problems)] |
| + if not input_api.is_committing: |
| + return [output_api.PresubmitPromptWarning(_TEST_ONLY_WARNING, problems)] |
| + else: |
| + # We don't warn on commit, to avoid stopping commits going through CQ. |
| + return [output_api.PresubmitNotifyResult(_TEST_ONLY_WARNING, problems)] |
| else: |
| return [] |