Re-enable these tests as they are no longer failing.
[chromium-blink-merge.git] / chrome / PRESUBMIT.py
blob8bf83c5b73e0f1155dcf9f249eef52d5878b3f74
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
3 # found in the LICENSE file.
5 """Presubmit script for changes affecting chrome/
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl.
9 """
11 import re
13 INCLUDE_CPP_FILES_ONLY = (
14 r'.*\.cc$', r'.*\.h$'
17 EXCLUDE = (
18 # Objective C confuses everything.
19 r'.*cocoa.*',
20 r'.*_mac\.(cc|h)$',
21 r'.*_mac_.*',
22 # All the messages files do weird multiple include trickery
23 r'.*_messages_internal\.h$',
24 r'render_messages.h$',
25 # Autogenerated window resources files are off limits
26 r'.*resource.h$',
27 # GTK macros in C-ish header code cause false positives
28 r'gtk_.*\.h$',
29 # Header trickery
30 r'.*-inl\.h$',
31 # Templates
32 r'sigslotrepeater\.h$',
33 # GCC attribute trickery
34 r'sel_main\.cc$',
35 # Mozilla code
36 r'mork_reader\.h$',
37 r'mork_reader\.cc$',
38 r'nss_decryptor_linux\.cc$',
39 # Has safe printf usage that cpplint complains about
40 r'safe_browsing_util\.cc$',
41 # Too much math on one line?
42 r'bloom_filter\.cc$',
43 # Bogus ifdef tricks
44 r'renderer_webkitplatformsupport_impl\.cc$',
45 # Lines > 100 chars
46 r'gcapi\.cc$',
49 def _CheckChangeLintsClean(input_api, output_api):
50 """Makes sure that the chrome/ code is cpplint clean."""
51 black_list = input_api.DEFAULT_BLACK_LIST + EXCLUDE
52 sources = lambda x: input_api.FilterSourceFile(
53 x, white_list=INCLUDE_CPP_FILES_ONLY, black_list=black_list)
54 return input_api.canned_checks.CheckChangeLintsClean(
55 input_api, output_api, sources)
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
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))
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)]
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))
80 return results
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
88 def CheckChangeOnCommit(input_api, output_api):
89 results = []
90 results.extend(_CommonChecks(input_api, output_api))
91 return results