Use more sensible behavior in presubmit checks.
It's less annoying to type Y than to have to rerun the scripts with --no_presubmit for certain checks.
TEST=none
BUG=none
TBR=joi
Review URL: http://codereview.chromium.org/119284
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@17838 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index 09439fb..ba8c3ed 100755
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -74,7 +74,7 @@
"""
for f, line_num, line in input_api.RightHandSideLines():
if '\t' in line:
- return [output_api.PresubmitError(
+ return [output_api.PresubmitPromptWarning(
"Found a tab character in %s, line %s" %
(f.LocalPath(), line_num))]
return []
@@ -103,14 +103,15 @@
def CheckTreeIsOpen(input_api, output_api, url, closed):
"""Checks that an url's content doesn't match a regexp that would mean that
the tree is closed."""
+ assert(input_api.is_committing)
try:
connection = input_api.urllib2.urlopen(url)
status = connection.read()
connection.close()
if input_api.re.match(closed, status):
long_text = status + '\n' + url
- return [output_api.PresubmitError("The tree is closed.",
- long_text=long_text)]
+ return [output_api.PresubmitPromptWarning("The tree is closed.",
+ long_text=long_text)]
except IOError:
pass
return []
diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py
index 1b02026..fa7dd7e 100755
--- a/tests/presubmit_unittest.py
+++ b/tests/presubmit_unittest.py
@@ -925,7 +925,7 @@
def testCannedCheckChangeHasNoTabs(self):
self.TestContent(presubmit_canned_checks.CheckChangeHasNoTabs,
'blah blah', 'blah\tblah',
- presubmit.OutputApi.PresubmitError)
+ presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckLongLines(self):
check = lambda x,y: presubmit_canned_checks.CheckLongLines(x, y, 10)
@@ -934,6 +934,7 @@
def testCannedCheckTreeIsOpenOpen(self):
input_api = self.MockInputApi()
+ input_api.is_committing = True
connection = self.mox.CreateMockAnything()
input_api.urllib2.urlopen('url_to_open').AndReturn(connection)
connection.read().AndReturn('1')
@@ -945,6 +946,7 @@
def testCannedCheckTreeIsOpenClosed(self):
input_api = self.MockInputApi()
+ input_api.is_committing = True
connection = self.mox.CreateMockAnything()
input_api.urllib2.urlopen('url_to_closed').AndReturn(connection)
connection.read().AndReturn('0')
@@ -954,7 +956,7 @@
input_api, presubmit.OutputApi, url='url_to_closed', closed='0')
self.assertEquals(len(results), 1)
self.assertEquals(results[0].__class__,
- presubmit.OutputApi.PresubmitError)
+ presubmit.OutputApi.PresubmitPromptWarning)
def testRunPythonUnitTestsNoTest(self):
input_api = self.MockInputApi()