Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: cc/PRESUBMIT.py

Issue 947983003: cc: Use the Lint function from depot_tools' presubmit_canned_checks API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cpp_lint_state Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 """Top-level presubmit script for cc. 5 """Top-level presubmit script for cc.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools. 8 for more details about the presubmit API built into depot_tools.
9 """ 9 """
10 10
11 import re 11 import re
12 import string 12 import string
13 13
14 CC_SOURCE_FILES=(r'^cc[\\/].*\.(cc|h)$',) 14 CC_SOURCE_FILES=(r'^cc[\\/].*\.(cc|h)$',)
15 15
16 def CheckChangeLintsClean(input_api, output_api): 16 def CheckChangeLintsClean(input_api, output_api):
17 input_api.cpplint._cpplint_state.ResetErrorCounts() # reset global state
18 source_filter = lambda x: input_api.FilterSourceFile( 17 source_filter = lambda x: input_api.FilterSourceFile(
19 x, white_list=CC_SOURCE_FILES, black_list=None) 18 x, white_list=CC_SOURCE_FILES, black_list=None)
20 files = [f.AbsoluteLocalPath() for f in
21 input_api.AffectedSourceFiles(source_filter)]
22 level = 1 # strict, but just warn
23 19
24 for file_name in files: 20 return input_api.canned_checks.CheckChangeLintsClean(
25 input_api.cpplint.ProcessFile(file_name, level) 21 input_api, output_api, source_filter, lint_filters=[], verbose_level=1)
26
27 if not input_api.cpplint._cpplint_state.error_count:
28 return []
29
30 return [output_api.PresubmitPromptWarning(
31 'Changelist failed cpplint.py check.')]
32 22
33 def CheckAsserts(input_api, output_api, white_list=CC_SOURCE_FILES, black_list=N one): 23 def CheckAsserts(input_api, output_api, white_list=CC_SOURCE_FILES, black_list=N one):
34 black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST) 24 black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST)
35 source_file_filter = lambda x: input_api.FilterSourceFile(x, white_list, black _list) 25 source_file_filter = lambda x: input_api.FilterSourceFile(x, white_list, black _list)
36 26
37 assert_files = [] 27 assert_files = []
38 notreached_files = [] 28 notreached_files = []
39 29
40 for f in input_api.AffectedSourceFiles(source_file_filter): 30 for f in input_api.AffectedSourceFiles(source_file_filter):
41 contents = input_api.ReadFile(f, 'rb') 31 contents = input_api.ReadFile(f, 'rb')
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 results += FindUselessIfdefs(input_api, output_api) 326 results += FindUselessIfdefs(input_api, output_api)
337 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api) 327 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api)
338 return results 328 return results
339 329
340 def GetPreferredTryMasters(project, change): 330 def GetPreferredTryMasters(project, change):
341 return { 331 return {
342 'tryserver.blink': { 332 'tryserver.blink': {
343 'linux_blink_rel': set(['defaulttests']), 333 'linux_blink_rel': set(['defaulttests']),
344 }, 334 },
345 } 335 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698