blob: 007797ea345cd7dcd5d645c55e1ffde9cc01f111 [file] [log] [blame]
kjellander@webrtc.orge61da8c2013-10-17 14:16:17 +00001#!/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"""
11Copied from Chrome's src/tools/lsan/PRESUBMIT.py
12
13See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
14for more details on the presubmit API built into gcl.
15"""
16
17import re
18
19def 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
36def CheckChangeOnUpload(input_api, output_api):
37 return CheckChange(input_api, output_api)
38
39def CheckChangeOnCommit(input_api, output_api):
40 return CheckChange(input_api, output_api)
41
42def GetPreferredTrySlaves():
43 return ['linux_asan']