kjellander@webrtc.org | e61da8c | 2013-10-17 14:16:17 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 | # |
| 4 | # Use of this source code is governed by a BSD-style license |
| 5 | # that can be found in the LICENSE file in the root of the source |
| 6 | # tree. An additional intellectual property rights grant can be found |
| 7 | # in the file PATENTS. All contributing project authors may |
| 8 | # be found in the AUTHORS file in the root of the source tree. |
| 9 | |
| 10 | """ |
| 11 | Copied from Chrome's src/tools/lsan/PRESUBMIT.py |
| 12 | |
| 13 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 14 | for more details on the presubmit API built into gcl. |
| 15 | """ |
| 16 | |
| 17 | import re |
| 18 | |
| 19 | def CheckChange(input_api, output_api): |
| 20 | errors = [] |
| 21 | |
| 22 | for f in input_api.AffectedFiles(): |
| 23 | if not f.LocalPath().endswith('suppressions.txt'): |
| 24 | continue |
| 25 | for line_num, line in enumerate(f.NewContents()): |
| 26 | line = line.strip() |
| 27 | if line.startswith('#') or not line: |
| 28 | continue |
| 29 | if not line.startswith('leak:'): |
| 30 | errors.append('"%s" should be "leak:..." in %s line %d' % |
| 31 | (line, f.LocalPath(), line_num)) |
| 32 | if errors: |
| 33 | return [output_api.PresubmitError('\n'.join(errors))] |
| 34 | return [] |
| 35 | |
| 36 | def CheckChangeOnUpload(input_api, output_api): |
| 37 | return CheckChange(input_api, output_api) |
| 38 | |
| 39 | def CheckChangeOnCommit(input_api, output_api): |
| 40 | return CheckChange(input_api, output_api) |
| 41 | |
| 42 | def GetPreferredTrySlaves(): |
| 43 | return ['linux_asan'] |