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
experimental/szager/collated-output
maruel@chromium.org 17 years ago
parent d7dccf5614
commit 8949138ee9

@ -74,7 +74,7 @@ def CheckChangeHasNoTabs(input_api, output_api):
""" """
for f, line_num, line in input_api.RightHandSideLines(): for f, line_num, line in input_api.RightHandSideLines():
if '\t' in line: if '\t' in line:
return [output_api.PresubmitError( return [output_api.PresubmitPromptWarning(
"Found a tab character in %s, line %s" % "Found a tab character in %s, line %s" %
(f.LocalPath(), line_num))] (f.LocalPath(), line_num))]
return [] return []
@ -103,14 +103,15 @@ def CheckLongLines(input_api, output_api, maxlen=80):
def CheckTreeIsOpen(input_api, output_api, url, closed): def CheckTreeIsOpen(input_api, output_api, url, closed):
"""Checks that an url's content doesn't match a regexp that would mean that """Checks that an url's content doesn't match a regexp that would mean that
the tree is closed.""" the tree is closed."""
assert(input_api.is_committing)
try: try:
connection = input_api.urllib2.urlopen(url) connection = input_api.urllib2.urlopen(url)
status = connection.read() status = connection.read()
connection.close() connection.close()
if input_api.re.match(closed, status): if input_api.re.match(closed, status):
long_text = status + '\n' + url long_text = status + '\n' + url
return [output_api.PresubmitError("The tree is closed.", return [output_api.PresubmitPromptWarning("The tree is closed.",
long_text=long_text)] long_text=long_text)]
except IOError: except IOError:
pass pass
return [] return []

@ -925,7 +925,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
def testCannedCheckChangeHasNoTabs(self): def testCannedCheckChangeHasNoTabs(self):
self.TestContent(presubmit_canned_checks.CheckChangeHasNoTabs, self.TestContent(presubmit_canned_checks.CheckChangeHasNoTabs,
'blah blah', 'blah\tblah', 'blah blah', 'blah\tblah',
presubmit.OutputApi.PresubmitError) presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckLongLines(self): def testCannedCheckLongLines(self):
check = lambda x,y: presubmit_canned_checks.CheckLongLines(x, y, 10) check = lambda x,y: presubmit_canned_checks.CheckLongLines(x, y, 10)
@ -934,6 +934,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
def testCannedCheckTreeIsOpenOpen(self): def testCannedCheckTreeIsOpenOpen(self):
input_api = self.MockInputApi() input_api = self.MockInputApi()
input_api.is_committing = True
connection = self.mox.CreateMockAnything() connection = self.mox.CreateMockAnything()
input_api.urllib2.urlopen('url_to_open').AndReturn(connection) input_api.urllib2.urlopen('url_to_open').AndReturn(connection)
connection.read().AndReturn('1') connection.read().AndReturn('1')
@ -945,6 +946,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
def testCannedCheckTreeIsOpenClosed(self): def testCannedCheckTreeIsOpenClosed(self):
input_api = self.MockInputApi() input_api = self.MockInputApi()
input_api.is_committing = True
connection = self.mox.CreateMockAnything() connection = self.mox.CreateMockAnything()
input_api.urllib2.urlopen('url_to_closed').AndReturn(connection) input_api.urllib2.urlopen('url_to_closed').AndReturn(connection)
connection.read().AndReturn('0') connection.read().AndReturn('0')
@ -954,7 +956,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
input_api, presubmit.OutputApi, url='url_to_closed', closed='0') input_api, presubmit.OutputApi, url='url_to_closed', closed='0')
self.assertEquals(len(results), 1) self.assertEquals(len(results), 1)
self.assertEquals(results[0].__class__, self.assertEquals(results[0].__class__,
presubmit.OutputApi.PresubmitError) presubmit.OutputApi.PresubmitPromptWarning)
def testRunPythonUnitTestsNoTest(self): def testRunPythonUnitTestsNoTest(self):
input_api = self.MockInputApi() input_api = self.MockInputApi()

Loading…
Cancel
Save