Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: PRESUBMIT_test.py

Issue 11496010: PRESUBMIT #include check: don't add a warning if we're committing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT_test.py
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 9bc7db5dd2f1e4e4a5d3d936dea2f227e47646dc..a8bbc8088b14f56a8f43c5a64f5b5b23631fc0f6 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):
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698