Add intro to any Chrome app API with no overview docs.
[chromium-blink-merge.git] / cc / PRESUBMIT.py
blobc876419762ee6f29a0460154974d855b69e0ca98
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Top-level presubmit script for cc.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
8 details on the presubmit API built into gcl.
9 """
11 import re
13 CC_SOURCE_FILES=(r'^cc/.*\.(cc|h)$',)
15 def CheckAsserts(input_api, output_api, white_list=CC_SOURCE_FILES, black_list=None):
16 black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST)
17 source_file_filter = lambda x: input_api.FilterSourceFile(x, white_list, black_list)
19 assert_files = []
20 notreached_files = []
22 for f in input_api.AffectedSourceFiles(source_file_filter):
23 contents = input_api.ReadFile(f, 'rb')
24 # WebKit ASSERT() is not allowed.
25 if re.search(r"\bASSERT\(", contents):
26 assert_files.append(f.LocalPath())
27 # WebKit ASSERT_NOT_REACHED() is not allowed.
28 if re.search(r"ASSERT_NOT_REACHED\(", contents):
29 notreached_files.append(f.LocalPath())
31 if assert_files:
32 return [output_api.PresubmitError(
33 'These files use ASSERT instead of using DCHECK:',
34 items=assert_files)]
35 if notreached_files:
36 return [output_api.PresubmitError(
37 'These files use ASSERT_NOT_REACHED instead of using NOTREACHED:',
38 items=notreached_files)]
39 return []
41 def CheckChangeOnUpload(input_api, output_api):
42 results = []
43 results += CheckAsserts(input_api, output_api)
44 return results
46 def GetPreferredTrySlaves(project, change):
47 return [
48 'linux_layout_rel',