| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 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 import re |
| 11 |
| 10 def CheckChange(input_api, output_api): | 12 def CheckChange(input_api, output_api): |
| 11 """Checks the memcheck suppressions files for bad data.""" | 13 """Checks the memcheck suppressions files for bad data.""" |
| 14 sup_regex = re.compile('suppressions.*\.txt$') |
| 12 suppressions = {} | 15 suppressions = {} |
| 13 errors = [] | 16 errors = [] |
| 14 check_for_memcheck = False | 17 check_for_memcheck = False |
| 15 # skip_next_line has 3 possible values: | 18 # skip_next_line has 3 possible values: |
| 16 # - False: don't skip the next line. | 19 # - False: don't skip the next line. |
| 17 # - 'skip_suppression_name': the next line is a suppression name, skip. | 20 # - 'skip_suppression_name': the next line is a suppression name, skip. |
| 18 # - 'skip_param': the next line is a system call parameter error, skip. | 21 # - 'skip_param': the next line is a system call parameter error, skip. |
| 19 skip_next_line = False | 22 skip_next_line = False |
| 20 for f in filter(lambda x: x.LocalPath().endswith('.txt'), | 23 for f in filter(lambda x: sup_regex.search(x.LocalPath()), |
| 21 input_api.AffectedFiles()): | 24 input_api.AffectedFiles()): |
| 22 for line, line_num in zip(f.NewContents(), | 25 for line, line_num in zip(f.NewContents(), |
| 23 xrange(1, len(f.NewContents()) + 1)): | 26 xrange(1, len(f.NewContents()) + 1)): |
| 24 line = line.lstrip() | 27 line = line.lstrip() |
| 25 if line.startswith('#') or not line: | 28 if line.startswith('#') or not line: |
| 26 continue | 29 continue |
| 27 | 30 |
| 28 if skip_next_line: | 31 if skip_next_line: |
| 29 if skip_next_line == 'skip_suppression_name': | 32 if skip_next_line == 'skip_suppression_name': |
| 30 if suppressions.has_key(line): | 33 if suppressions.has_key(line): |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 return [] | 69 return [] |
| 67 | 70 |
| 68 def CheckChangeOnUpload(input_api, output_api): | 71 def CheckChangeOnUpload(input_api, output_api): |
| 69 return CheckChange(input_api, output_api) | 72 return CheckChange(input_api, output_api) |
| 70 | 73 |
| 71 def CheckChangeOnCommit(input_api, output_api): | 74 def CheckChangeOnCommit(input_api, output_api): |
| 72 return CheckChange(input_api, output_api) | 75 return CheckChange(input_api, output_api) |
| 73 | 76 |
| 74 def GetPreferredTrySlaves(): | 77 def GetPreferredTrySlaves(): |
| 75 return ['linux_valgrind', 'mac_valgrind'] | 78 return ['linux_valgrind', 'mac_valgrind'] |
| OLD | NEW |