diff options
author | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 17:55:53 +0000 |
---|---|---|
committer | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 17:55:53 +0000 |
commit | 120cf540da701f19e9017cf7e603b2946aa88530 (patch) | |
tree | f086c201e9fc87ca0683003f384528cea2ac68bb /PRESUBMIT_test.py | |
parent | b12f1be3dea384b60106cedeae8f2eaa711b95ae (diff) | |
download | chromium_src-120cf540da701f19e9017cf7e603b2946aa88530.zip chromium_src-120cf540da701f19e9017cf7e603b2946aa88530.tar.gz chromium_src-120cf540da701f19e9017cf7e603b2946aa88530.tar.bz2 |
PRESUBMIT #include check: don't add a warning if we're committing.
This enables the commit queue to commit patches where the #include order is
"wrong" according to the check.
NOTRY=true
BUG=
Review URL: https://chromiumcodereview.appspot.com/11496010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT_test.py')
-rwxr-xr-x | PRESUBMIT_test.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py index 9bc7db5..a8bbc80 100755 --- a/PRESUBMIT_test.py +++ b/PRESUBMIT_test.py @@ -15,6 +15,7 @@ class MockInputApi(object): self.re = re self.os_path = os.path self.files = [] + self.is_committing = False def AffectedFiles(self): return self.files @@ -30,14 +31,17 @@ class MockOutputApi(object): class PresubmitError(PresubmitResult): def __init__(self, message, items, long_text=''): MockOutputApi.PresubmitResult.__init__(self, message, items, long_text) + self.type = 'error' class PresubmitPromptWarning(PresubmitResult): def __init__(self, message, items, long_text=''): MockOutputApi.PresubmitResult.__init__(self, message, items, long_text) + self.type = 'warning' class PresubmitNotifyResult(PresubmitResult): def __init__(self, message, items, long_text=''): MockOutputApi.PresubmitResult.__init__(self, message, items, long_text) + self.type = 'notify' class MockFile(object): @@ -234,6 +238,19 @@ class IncludeOrderTest(unittest.TestCase): warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api) self.assertEqual(1, len(warnings)) self.assertEqual(2, len(warnings[0].items)) + self.assertEqual('warning', warnings[0].type) + + def testOnlyNotifyOnCommit(self): + mock_input_api = MockInputApi() + mock_input_api.is_committing = True + mock_output_api = MockOutputApi() + contents = ['#include <b.h>', + '#include <a.h>'] + mock_input_api.files = [MockFile('something.cc', contents)] + warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api) + self.assertEqual(1, len(warnings)) + self.assertEqual(1, len(warnings[0].items)) + self.assertEqual('notify', warnings[0].type) class VersionControlerConflictsTest(unittest.TestCase): |