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

Side by Side Diff: chrome/PRESUBMIT.py

Issue 8728012: Add a presubmit check so that no new unit tests in content/ are added to the unit_tests target (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years 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 | Annotate | Revision Log
« 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) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 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 """Makes sure that the chrome/ code is cpplint clean.""" 5 """Presubmit script for changes affecting chrome/
6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl.
9 """
10
11 import re
6 12
7 INCLUDE_CPP_FILES_ONLY = ( 13 INCLUDE_CPP_FILES_ONLY = (
8 r'.*\.cc$', r'.*\.h$' 14 r'.*\.cc$', r'.*\.h$'
9 ) 15 )
10 16
11 EXCLUDE = ( 17 EXCLUDE = (
12 # Objective C confuses everything. 18 # Objective C confuses everything.
13 r'.*cocoa.*', 19 r'.*cocoa.*',
14 r'.*_mac\.(cc|h)$', 20 r'.*_mac\.(cc|h)$',
15 r'.*_mac_.*', 21 r'.*_mac_.*',
(...skipping 17 matching lines...) Expand all
33 # Has safe printf usage that cpplint complains about 39 # Has safe printf usage that cpplint complains about
34 r'safe_browsing_util\.cc$', 40 r'safe_browsing_util\.cc$',
35 # Too much math on one line? 41 # Too much math on one line?
36 r'bloom_filter\.cc$', 42 r'bloom_filter\.cc$',
37 # Bogus ifdef tricks 43 # Bogus ifdef tricks
38 r'renderer_webkitplatformsupport_impl\.cc$', 44 r'renderer_webkitplatformsupport_impl\.cc$',
39 # Lines > 100 chars 45 # Lines > 100 chars
40 r'gcapi\.cc$', 46 r'gcapi\.cc$',
41 ) 47 )
42 48
43 def CheckChangeOnUpload(input_api, output_api): 49 def _CheckChangeLintsClean(input_api, output_api):
44 results = [] 50 """Makes sure that the chrome/ code is cpplint clean."""
45 black_list = input_api.DEFAULT_BLACK_LIST + EXCLUDE 51 black_list = input_api.DEFAULT_BLACK_LIST + EXCLUDE
46 sources = lambda x: input_api.FilterSourceFile( 52 sources = lambda x: input_api.FilterSourceFile(
47 x, white_list=INCLUDE_CPP_FILES_ONLY, black_list=black_list) 53 x, white_list=INCLUDE_CPP_FILES_ONLY, black_list=black_list)
48 results.extend(input_api.canned_checks.CheckChangeLintsClean( 54 return input_api.canned_checks.CheckChangeLintsClean(
49 input_api, output_api, sources)) 55 input_api, output_api, sources)
56
57 def _CheckNoContentUnitTestsInChrome(input_api, output_api):
58 """Makes sure that no unit tests from content/ are included in unit_tests."""
59 problems = []
60 for f in input_api.AffectedFiles():
61 if not f.LocalPath().endswith('chrome_tests.gypi'):
62 continue
63
64 for line_num, line in f.ChangedContents():
65 m = re.search(r"'(.*\/content\/.*unittest.*)'", line)
66 if m:
67 problems.append(m.group(1))
68
69 if not problems:
70 return []
71 return [output_api.PresubmitPromptWarning(
72 'Unit tests located in content/ should be added to the ' +
73 'content_tests.gypi:content_unittests target.',
74 items=problems)]
75
76 def _CommonChecks(input_api, output_api):
77 """Checks common to both upload and commit."""
78 results = []
79 results.extend(_CheckNoContentUnitTestsInChrome(input_api, output_api))
50 return results 80 return results
81
82 def CheckChangeOnUpload(input_api, output_api):
83 results = []
84 results.extend(_CommonChecks(input_api, output_api))
85 results.extend(_CheckChangeLintsClean(input_api, output_api))
86 return results
87
88 def CheckChangeOnCommit(input_api, output_api):
89 results = []
90 results.extend(_CommonChecks(input_api, output_api))
91 return results
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