Commit 8949138e authored by maruel@chromium.org's avatar maruel@chromium.org

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
parent d7dccf56
......@@ -74,7 +74,7 @@ def CheckChangeHasNoTabs(input_api, output_api):
"""
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 CheckLongLines(input_api, output_api, maxlen=80):
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 []
......
......@@ -925,7 +925,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
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 @@ class CannedChecksUnittest(PresubmitTestsBase):
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 @@ class CannedChecksUnittest(PresubmitTestsBase):
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 @@ class CannedChecksUnittest(PresubmitTestsBase):
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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment