Update PRESUBMIT scripts to use PresubmitPromptOrNotify helper.
NOTRY=true Review URL: https://chromiumcodereview.appspot.com/13093006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191863 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
29
PRESUBMIT.py
29
PRESUBMIT.py
@@ -223,11 +223,7 @@ def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api):
|
|||||||
line_number += 1
|
line_number += 1
|
||||||
|
|
||||||
if problems:
|
if problems:
|
||||||
if not input_api.is_committing:
|
return [output_api.PresubmitPromptOrNotify(_TEST_ONLY_WARNING, problems)]
|
||||||
return [output_api.PresubmitPromptWarning(_TEST_ONLY_WARNING, problems)]
|
|
||||||
else:
|
|
||||||
# We don't warn on commit, to avoid stopping commits going through CQ.
|
|
||||||
return [output_api.PresubmitNotifyResult(_TEST_ONLY_WARNING, problems)]
|
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@@ -440,13 +436,7 @@ def _CheckUnwantedDependencies(input_api, output_api):
|
|||||||
'You added one or more #includes that violate checkdeps rules.',
|
'You added one or more #includes that violate checkdeps rules.',
|
||||||
error_descriptions))
|
error_descriptions))
|
||||||
if warning_descriptions:
|
if warning_descriptions:
|
||||||
if not input_api.is_committing:
|
results.append(output_api.PresubmitPromptOrNotify(
|
||||||
warning_factory = output_api.PresubmitPromptWarning
|
|
||||||
else:
|
|
||||||
# We don't want to block use of the CQ when there is a warning
|
|
||||||
# of this kind, so we only show a message when committing.
|
|
||||||
warning_factory = output_api.PresubmitNotifyResult
|
|
||||||
results.append(warning_factory(
|
|
||||||
'You added one or more #includes of files that are temporarily\n'
|
'You added one or more #includes of files that are temporarily\n'
|
||||||
'allowed but being removed. Can you avoid introducing the\n'
|
'allowed but being removed. Can you avoid introducing the\n'
|
||||||
'#include? See relevant DEPS file(s) for details and contacts.',
|
'#include? See relevant DEPS file(s) for details and contacts.',
|
||||||
@@ -623,12 +613,7 @@ def _CheckIncludeOrder(input_api, output_api):
|
|||||||
|
|
||||||
results = []
|
results = []
|
||||||
if warnings:
|
if warnings:
|
||||||
if not input_api.is_committing:
|
results.append(output_api.PresubmitPromptOrNotify(_INCLUDE_ORDER_WARNING,
|
||||||
results.append(output_api.PresubmitPromptWarning(_INCLUDE_ORDER_WARNING,
|
|
||||||
warnings))
|
|
||||||
else:
|
|
||||||
# We don't warn on commit, to avoid stopping commits going through CQ.
|
|
||||||
results.append(output_api.PresubmitNotifyResult(_INCLUDE_ORDER_WARNING,
|
|
||||||
warnings))
|
warnings))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@@ -677,13 +662,7 @@ def _CheckHardcodedGoogleHostsInLowerLayers(input_api, output_api):
|
|||||||
problems.append((f.LocalPath(), line_num, line))
|
problems.append((f.LocalPath(), line_num, line))
|
||||||
|
|
||||||
if problems:
|
if problems:
|
||||||
if not input_api.is_committing:
|
return [output_api.PresubmitPromptOrNotify(
|
||||||
warning_factory = output_api.PresubmitPromptWarning
|
|
||||||
else:
|
|
||||||
# We don't want to block use of the CQ when there is a warning
|
|
||||||
# of this kind, so we only show a message when committing.
|
|
||||||
warning_factory = output_api.PresubmitNotifyResult
|
|
||||||
return [warning_factory(
|
|
||||||
'Most layers below src/chrome/ should not hardcode service URLs.\n'
|
'Most layers below src/chrome/ should not hardcode service URLs.\n'
|
||||||
'Are you sure this is correct? (Contact: joi@chromium.org)',
|
'Are you sure this is correct? (Contact: joi@chromium.org)',
|
||||||
[' %s:%d: %s' % (
|
[' %s:%d: %s' % (
|
||||||
|
@@ -43,6 +43,11 @@ class MockOutputApi(object):
|
|||||||
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
|
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
|
||||||
self.type = 'notify'
|
self.type = 'notify'
|
||||||
|
|
||||||
|
class PresubmitPromptOrNotify(PresubmitResult):
|
||||||
|
def __init__(self, message, items, long_text=''):
|
||||||
|
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
|
||||||
|
self.type = 'promptOrNotify'
|
||||||
|
|
||||||
|
|
||||||
class MockFile(object):
|
class MockFile(object):
|
||||||
def __init__(self, local_path, new_contents):
|
def __init__(self, local_path, new_contents):
|
||||||
@@ -246,19 +251,7 @@ class IncludeOrderTest(unittest.TestCase):
|
|||||||
warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api)
|
warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api)
|
||||||
self.assertEqual(1, len(warnings))
|
self.assertEqual(1, len(warnings))
|
||||||
self.assertEqual(2, len(warnings[0].items))
|
self.assertEqual(2, len(warnings[0].items))
|
||||||
self.assertEqual('warning', warnings[0].type)
|
self.assertEqual('promptOrNotify', 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)
|
|
||||||
|
|
||||||
def testUncheckableIncludes(self):
|
def testUncheckableIncludes(self):
|
||||||
mock_input_api = MockInputApi()
|
mock_input_api = MockInputApi()
|
||||||
|
@@ -175,7 +175,7 @@ def CheckChange(input_api, output_api):
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
if line[2].split()[:2] == ['#define', 'PPAPI_RELEASE']:
|
if line[2].split()[:2] == ['#define', 'PPAPI_RELEASE']:
|
||||||
results.append(
|
results.append(
|
||||||
output_api.PresubmitNotifyResult(
|
output_api.PresubmitPromptOrNotify(
|
||||||
'PPAPI_RELEASE has changed', long_text=line[2]))
|
'PPAPI_RELEASE has changed', long_text=line[2]))
|
||||||
releaseChanged = True
|
releaseChanged = True
|
||||||
break
|
break
|
||||||
|
Reference in New Issue
Block a user