Commit ff5a87ad authored by dpranke@chromium.org's avatar dpranke@chromium.org

suppress messages for PresubmitAddText results

Review URL: http://codereview.chromium.org/6646040

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@77700 0039d316-1c4b-4281-b951-d872f2087c98
parent 3ae183fb
......@@ -154,12 +154,19 @@ class OutputApi(object):
"""Whether this presubmit result should result in a prompt warning."""
return False
def IsMessage(self):
"""Whether this result contains anything needing to be displayed."""
return True
class PresubmitAddText(PresubmitResult):
"""Propagates a line of text back to the caller."""
def __init__(self, message, items=None, long_text=''):
super(OutputApi.PresubmitAddText, self).__init__("ADD: " + message,
items, long_text)
def IsMessage(self):
return False
class PresubmitError(PresubmitResult):
"""A hard presubmit error."""
def IsFatal(self):
......@@ -1056,6 +1063,9 @@ def DoPresubmitChecks(change,
if items:
output_stream.write('** Presubmit %s **\n' % name)
for item in items:
if not item.IsMessage():
continue
# Access to a protected member XXX of a client class
# pylint: disable=W0212
if not item._Handle(output_stream, input_stream,
......
......@@ -1045,17 +1045,23 @@ class OuputApiUnittest(PresubmitTestsBase):
def testOutputApiBasics(self):
self.mox.ReplayAll()
self.failUnless(presubmit.OutputApi.PresubmitError('').IsFatal())
self.failUnless(presubmit.OutputApi.PresubmitError('').IsMessage())
self.failIf(presubmit.OutputApi.PresubmitError('').ShouldPrompt())
self.failIf(presubmit.OutputApi.PresubmitPromptWarning('').IsFatal())
self.failUnless(
presubmit.OutputApi.PresubmitPromptWarning('').ShouldPrompt())
self.failUnless(
presubmit.OutputApi.PresubmitPromptWarning('').IsMessage())
self.failIf(presubmit.OutputApi.PresubmitNotifyResult('').IsFatal())
self.failIf(presubmit.OutputApi.PresubmitNotifyResult('').ShouldPrompt())
self.failUnless(
presubmit.OutputApi.PresubmitNotifyResult('foo').IsMessage())
self.failIf(presubmit.OutputApi.PresubmitAddText('foo').IsFatal())
self.failIf(presubmit.OutputApi.PresubmitAddText('foo').ShouldPrompt())
self.failIf(presubmit.OutputApi.PresubmitAddText('foo').IsMessage())
# TODO(joi) Test MailTextResult once implemented.
......
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