Commit fdcc9f7f authored by estade@chromium.org's avatar estade@chromium.org

Add a presubmit test that asserts TODOs have owners.

For example, TODO(foo) is ok, but TODO: do something is not.

BUG=none
TEST=included

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@74032 0039d316-1c4b-4281-b951-d872f2087c98
parent 17f9e1f7
......@@ -234,6 +234,18 @@ def CheckChangeHasNoTabs(input_api, output_api, source_file_filter=None):
return []
def CheckChangeTodoHasOwner(input_api, output_api, source_file_filter=None):
"""Checks that the user didn't add TODO(name) without an owner."""
unowned_todo = input_api.re.compile('TO' + 'DO[^(]');
for f, line_num, line in input_api.RightHandSideLines(source_file_filter):
if unowned_todo.search(line):
text = ('Found TO' + 'DO with no owner in %s, line %s' %
(f.LocalPath(), line_num))
return [output_api.PresubmitPromptWarning(text)]
return []
def CheckChangeHasNoStrayWhitespace(input_api, output_api,
source_file_filter=None):
"""Checks that there is no stray whitespace at source lines end."""
......
......@@ -1131,6 +1131,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
'CheckChangeHasNoStrayWhitespace',
'CheckChangeHasOnlyOneEol', 'CheckChangeHasNoCR',
'CheckChangeHasNoCrAndHasOnlyOneEol', 'CheckChangeHasNoTabs',
'CheckChangeTodoHasOwner',
'CheckChangeHasQaField', 'CheckChangeHasTestedField',
'CheckChangeHasTestField',
'CheckChangeLintsClean',
......@@ -1309,7 +1310,6 @@ class CannedChecksUnittest(PresubmitTestsBase):
'Foo', 'Foo ',
presubmit.OutputApi.PresubmitPromptWarning)
def testCheckChangeHasOnlyOneEol(self):
self.ReadFileTest(presubmit_canned_checks.CheckChangeHasOnlyOneEol,
"Hey!\nHo!\n", "Hey!\nHo!\n\n",
......@@ -1331,6 +1331,11 @@ class CannedChecksUnittest(PresubmitTestsBase):
"Hey!\nHo!\n", "Hey!\r\nHo!\r\n",
presubmit.OutputApi.PresubmitPromptWarning)
def testCheckChangeTodoHasOwner(self):
self.ContentTest(presubmit_canned_checks.CheckChangeTodoHasOwner,
"TODO(foo): bar", "TODO: bar",
presubmit.OutputApi.PresubmitPromptWarning)
def testCannedCheckChangeHasNoTabs(self):
self.ContentTest(presubmit_canned_checks.CheckChangeHasNoTabs,
'blah blah', 'blah\tblah',
......
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