Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: presubmit_canned_checks.py

Issue 6413004: Add a presubmit test that asserts TODOs have owners.... (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Generic presubmit checks that can be reused by other presubmit checks.""" 5 """Generic presubmit checks that can be reused by other presubmit checks."""
6 6
7 ### Description checks 7 ### Description checks
8 8
9 def CheckChangeHasTestField(input_api, output_api): 9 def CheckChangeHasTestField(input_api, output_api):
10 """Requires that the changelist have a TEST= field.""" 10 """Requires that the changelist have a TEST= field."""
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 tabs = [] 227 tabs = []
228 for f, line_num, line in input_api.RightHandSideLines(filter_more): 228 for f, line_num, line in input_api.RightHandSideLines(filter_more):
229 if '\t' in line: 229 if '\t' in line:
230 tabs.append('%s, line %s' % (f.LocalPath(), line_num)) 230 tabs.append('%s, line %s' % (f.LocalPath(), line_num))
231 if tabs: 231 if tabs:
232 return [output_api.PresubmitPromptWarning('Found a tab character in:', 232 return [output_api.PresubmitPromptWarning('Found a tab character in:',
233 long_text='\n'.join(tabs))] 233 long_text='\n'.join(tabs))]
234 return [] 234 return []
235 235
236 236
237 def CheckChangeTodoHasOwner(input_api, output_api, source_file_filter=None):
238 """Checks that the user didn't add TODO(name) without an owner."""
239
240 unowned_todo = input_api.re.compile('TO' + 'DO[^(]');
241 for f, line_num, line in input_api.RightHandSideLines(source_file_filter):
242 if unowned_todo.search(line):
243 text = ('Found TO' + 'DO with no owner in %s, line %s' %
244 (f.LocalPath(), line_num))
245 return [output_api.PresubmitPromptWarning(text)]
246 return []
247
248
237 def CheckChangeHasNoStrayWhitespace(input_api, output_api, 249 def CheckChangeHasNoStrayWhitespace(input_api, output_api,
238 source_file_filter=None): 250 source_file_filter=None):
239 """Checks that there is no stray whitespace at source lines end.""" 251 """Checks that there is no stray whitespace at source lines end."""
240 errors = [] 252 errors = []
241 for f, line_num, line in input_api.RightHandSideLines(source_file_filter): 253 for f, line_num, line in input_api.RightHandSideLines(source_file_filter):
242 if line.rstrip() != line: 254 if line.rstrip() != line:
243 errors.append('%s, line %s' % (f.LocalPath(), line_num)) 255 errors.append('%s, line %s' % (f.LocalPath(), line_num))
244 if errors: 256 if errors:
245 return [output_api.PresubmitPromptWarning( 257 return [output_api.PresubmitPromptWarning(
246 'Found line ending with white spaces in:', 258 'Found line ending with white spaces in:',
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 pending_builds_len = len(builder.get('pending_builds', [])) 617 pending_builds_len = len(builder.get('pending_builds', []))
606 if pending_builds_len > max_pendings: 618 if pending_builds_len > max_pendings:
607 out.append('%s has %d build(s) pending' % 619 out.append('%s has %d build(s) pending' %
608 (builder_name, pending_builds_len)) 620 (builder_name, pending_builds_len))
609 if out: 621 if out:
610 return [output_api.PresubmitPromptWarning( 622 return [output_api.PresubmitPromptWarning(
611 'Build(s) pending. It is suggested to wait that no more than %d ' 623 'Build(s) pending. It is suggested to wait that no more than %d '
612 'builds are pending.' % max_pendings, 624 'builds are pending.' % max_pendings,
613 long_text='\n'.join(out))] 625 long_text='\n'.join(out))]
614 return [] 626 return []
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698