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

Side by Side Diff: base/PRESUBMIT.py

Issue 670073003: remove OVERRIDE/FINAL presubmit checks now the macros are gone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | cc/PRESUBMIT.py » ('j') | 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 """Chromium presubmit script for src/base. 5 """Chromium presubmit script for src/base.
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 on the presubmit API built into gcl. 8 for more details on the presubmit API built into gcl.
9 """ 9 """
10 10
11 import re
12
13 BASE_SOURCE_FILES=(r'^base/.*\.(cc|h|mm)$',)
14
15 def _CheckNoInterfacesInBase(input_api, output_api): 11 def _CheckNoInterfacesInBase(input_api, output_api):
16 """Checks to make sure no files in libbase.a have |@interface|.""" 12 """Checks to make sure no files in libbase.a have |@interface|."""
17 pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE) 13 pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE)
18 files = [] 14 files = []
19 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): 15 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
20 if (f.LocalPath().startswith('base/') and 16 if (f.LocalPath().startswith('base/') and
21 not "/test/" in f.LocalPath() and 17 not "/test/" in f.LocalPath() and
22 not f.LocalPath().endswith('_unittest.mm') and 18 not f.LocalPath().endswith('_unittest.mm') and
23 not f.LocalPath().endswith('mac/sdk_forward_declarations.h')): 19 not f.LocalPath().endswith('mac/sdk_forward_declarations.h')):
24 contents = input_api.ReadFile(f) 20 contents = input_api.ReadFile(f)
25 if pattern.search(contents): 21 if pattern.search(contents):
26 files.append(f) 22 files.append(f)
27 23
28 if len(files): 24 if len(files):
29 return [ output_api.PresubmitError( 25 return [ output_api.PresubmitError(
30 'Objective-C interfaces or categories are forbidden in libbase. ' + 26 'Objective-C interfaces or categories are forbidden in libbase. ' +
31 'See http://groups.google.com/a/chromium.org/group/chromium-dev/' + 27 'See http://groups.google.com/a/chromium.org/group/chromium-dev/' +
32 'browse_thread/thread/efb28c10435987fd', 28 'browse_thread/thread/efb28c10435987fd',
33 files) ] 29 files) ]
34 return [] 30 return []
35 31
36 32
37 def _CommonChecks(input_api, output_api): 33 def _CommonChecks(input_api, output_api):
38 """Checks common to both upload and commit.""" 34 """Checks common to both upload and commit."""
39 results = [] 35 results = []
40 results.extend(_CheckNoInterfacesInBase(input_api, output_api)) 36 results.extend(_CheckNoInterfacesInBase(input_api, output_api))
41 return results 37 return results
42 38
43 def _CheckOverrideFinal(input_api, output_api,
44 whitelist=BASE_SOURCE_FILES, blacklist=None):
45 """Make sure new lines of code don't use the OVERRIDE or FINAL macros."""
46
47 # TODO(mostynb): remove this check once the macros are removed
48 # from base/compiler_specific.h.
49
50 errors = []
51
52 source_file_filter = lambda x: input_api.FilterSourceFile(
53 x, white_list=BASE_SOURCE_FILES, black_list=None)
54
55 override_files = []
56 final_files = []
57
58 for f in input_api.AffectedSourceFiles(source_file_filter):
59 contents = input_api.ReadFile(f, 'rb')
60
61 # "override" and "final" should be used instead of OVERRIDE/FINAL now.
62 if re.search(r"\bOVERRIDE\b", contents):
63 override_files.append(f.LocalPath())
64
65 if re.search(r"\bFINAL\b", contents):
66 final_files.append(f.LocalPath())
67
68 if override_files:
69 return [output_api.PresubmitError(
70 'These files use OVERRIDE instead of using override:',
71 items=override_files)]
72 if final_files:
73 return [output_api.PresubmitError(
74 'These files use FINAL instead of using final:',
75 items=final_files)]
76
77 return []
78
79 def CheckChangeOnUpload(input_api, output_api): 39 def CheckChangeOnUpload(input_api, output_api):
80 results = [] 40 results = []
81 results.extend(_CheckOverrideFinal(input_api, output_api))
82 results.extend(_CommonChecks(input_api, output_api)) 41 results.extend(_CommonChecks(input_api, output_api))
83 return results 42 return results
84 43
85 44
86 def CheckChangeOnCommit(input_api, output_api): 45 def CheckChangeOnCommit(input_api, output_api):
87 results = [] 46 results = []
88 results.extend(_CommonChecks(input_api, output_api)) 47 results.extend(_CommonChecks(input_api, output_api))
89 return results 48 return results
90 49
91 50
92 def GetPreferredTryMasters(project, change): 51 def GetPreferredTryMasters(project, change):
93 return { 52 return {
94 'tryserver.chromium.linux': { 53 'tryserver.chromium.linux': {
95 'linux_chromium_rel_swarming': set(['defaulttests']), 54 'linux_chromium_rel_swarming': set(['defaulttests']),
96 }, 55 },
97 'tryserver.chromium.mac': { 56 'tryserver.chromium.mac': {
98 'mac_chromium_rel_swarming': set(['defaulttests']), 57 'mac_chromium_rel_swarming': set(['defaulttests']),
99 }, 58 },
100 'tryserver.chromium.win': { 59 'tryserver.chromium.win': {
101 'win_chromium_rel_swarming': set(['defaulttests']), 60 'win_chromium_rel_swarming': set(['defaulttests']),
102 } 61 }
103 } 62 }
OLDNEW
« no previous file with comments | « no previous file | cc/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698