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

Side by Side Diff: tools/heapcheck/PRESUBMIT.py

Issue 3343020: Add a presubmit check to look for duplicate Valgrind/Heapchecker suppression name... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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 | tools/valgrind/memcheck/PRESUBMIT.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 """ 5 """
6 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 6 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
7 for more details on the presubmit API built into gcl. 7 for more details on the presubmit API built into gcl.
8 """ 8 """
9 9
10 def CheckChange(input_api, output_api): 10 def CheckChange(input_api, output_api):
11 """Checks the memcheck suppressions files for bad data.""" 11 """Checks the memcheck suppressions files for bad data."""
12 suppressions = {}
12 errors = [] 13 errors = []
13 skip_next_line = False 14 skip_next_line = False
14 func_re = input_api.re.compile('[a-z_.]+\(.+\)$') 15 func_re = input_api.re.compile('[a-z_.]+\(.+\)$')
15 for f, line_num, line in input_api.RightHandSideLines(lambda x: 16 for f, line_num, line in input_api.RightHandSideLines(lambda x:
16 x.LocalPath().endswith('.txt')): 17 x.LocalPath().endswith('.txt')):
17 line = line.lstrip() 18 line = line.lstrip()
18 if line.startswith('#') or not line: 19 if line.startswith('#') or not line:
19 continue 20 continue
20 21
21 if skip_next_line: 22 if skip_next_line:
23 if suppressions.has_key(line):
24 errors.append('suppression with name "%s" at %s line %s has already '
25 'been defined at line %s' % (line, f.LocalPath(),
26 line_num,
27 suppressions[line][1]))
28 else:
29 suppressions[line] = (f, line_num)
22 skip_next_line = False 30 skip_next_line = False
23 continue 31 continue
24 if line == '{': 32 if line == '{':
25 skip_next_line = True 33 skip_next_line = True
26 continue 34 continue
27 if (line.startswith('fun:') or line.startswith('obj:') or 35 if (line.startswith('fun:') or line.startswith('obj:') or
28 line == 'Heapcheck:Leak' or line == '}' or 36 line == 'Heapcheck:Leak' or line == '}' or
29 line == '...'): 37 line == '...'):
30 continue 38 continue
31 if func_re.match(line): 39 if func_re.match(line):
32 continue 40 continue
33 errors.append('"%s" is probably wrong: %s line %s' % (line, f.LocalPath(), 41 errors.append('"%s" is probably wrong: %s line %s' % (line, f.LocalPath(),
34 line_num)) 42 line_num))
35 if errors: 43 if errors:
36 return [output_api.PresubmitError('\n'.join(errors))] 44 return [output_api.PresubmitError('\n'.join(errors))]
37 return [] 45 return []
38 46
39 def CheckChangeOnUpload(input_api, output_api): 47 def CheckChangeOnUpload(input_api, output_api):
40 return CheckChange(input_api, output_api) 48 return CheckChange(input_api, output_api)
41 49
42 def CheckChangeOnCommit(input_api, output_api): 50 def CheckChangeOnCommit(input_api, output_api):
43 return CheckChange(input_api, output_api) 51 return CheckChange(input_api, output_api)
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/memcheck/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698