summaryrefslogtreecommitdiffstats
path: root/tools/lsan/PRESUBMIT.py
blob: 248cdaf49f588aa559b96d903ceaf2e084cb23d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details on the presubmit API built into gcl.
"""

import re

def CheckChange(input_api, output_api):
  errors = []

  for f in input_api.AffectedFiles():
    if not f.LocalPath().endswith('suppressions.txt'):
      continue
    for line_num, line in enumerate(f.NewContents()):
      line = line.strip()
      if line.startswith('#') or not line:
        continue
      if not line.startswith('leak:'):
        errors.append('"%s" should be "leak:..." in %s line %d' %
                      (line, f.LocalPath(), line_num))
  if errors:
    return [output_api.PresubmitError('\n'.join(errors))]
  return []

def CheckChangeOnUpload(input_api, output_api):
  return CheckChange(input_api, output_api)

def CheckChangeOnCommit(input_api, output_api):
  return CheckChange(input_api, output_api)

def GetPreferredTryMasters(project, change):
  return {
    'tryserver.chromium': {
      'linux_asan': set(['compile']),
      'mac_asan': set(['compile']),
    }
  }