Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 import re |
|
Jói
2011/11/29 09:10:30
Please improve the docstring rather than removing
jochen (gone - plz use gerrit)
2011/11/29 13:01:11
Done.
| |
| 6 | 6 |
| 7 INCLUDE_CPP_FILES_ONLY = ( | 7 INCLUDE_CPP_FILES_ONLY = ( |
| 8 r'.*\.cc$', r'.*\.h$' | 8 r'.*\.cc$', r'.*\.h$' |
| 9 ) | 9 ) |
| 10 | 10 |
| 11 EXCLUDE = ( | 11 EXCLUDE = ( |
| 12 # Objective C confuses everything. | 12 # Objective C confuses everything. |
| 13 r'.*cocoa.*', | 13 r'.*cocoa.*', |
| 14 r'.*_mac\.(cc|h)$', | 14 r'.*_mac\.(cc|h)$', |
| 15 r'.*_mac_.*', | 15 r'.*_mac_.*', |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 33 # Has safe printf usage that cpplint complains about | 33 # Has safe printf usage that cpplint complains about |
| 34 r'safe_browsing_util\.cc$', | 34 r'safe_browsing_util\.cc$', |
| 35 # Too much math on one line? | 35 # Too much math on one line? |
| 36 r'bloom_filter\.cc$', | 36 r'bloom_filter\.cc$', |
| 37 # Bogus ifdef tricks | 37 # Bogus ifdef tricks |
| 38 r'renderer_webkitplatformsupport_impl\.cc$', | 38 r'renderer_webkitplatformsupport_impl\.cc$', |
| 39 # Lines > 100 chars | 39 # Lines > 100 chars |
| 40 r'gcapi\.cc$', | 40 r'gcapi\.cc$', |
| 41 ) | 41 ) |
| 42 | 42 |
| 43 def CheckChangeOnUpload(input_api, output_api): | 43 def _CheckChangeLintsClean(input_api, output_api): |
| 44 results = [] | 44 """Makes sure that the chrome/ code is cpplint clean.""" |
| 45 black_list = input_api.DEFAULT_BLACK_LIST + EXCLUDE | 45 black_list = input_api.DEFAULT_BLACK_LIST + EXCLUDE |
| 46 sources = lambda x: input_api.FilterSourceFile( | 46 sources = lambda x: input_api.FilterSourceFile( |
| 47 x, white_list=INCLUDE_CPP_FILES_ONLY, black_list=black_list) | 47 x, white_list=INCLUDE_CPP_FILES_ONLY, black_list=black_list) |
| 48 results.extend(input_api.canned_checks.CheckChangeLintsClean( | 48 return input_api.canned_checks.CheckChangeLintsClean( |
| 49 input_api, output_api, sources)) | 49 input_api, output_api, sources) |
| 50 | |
| 51 def _CheckNoContentUnitTestsInChrome(input_api, output_api): | |
| 52 """Makes sure that no unit tests from content/ are included in unit_tests.""" | |
| 53 problems = [] | |
| 54 for f in input_api.AffectedFiles(): | |
| 55 if not f.LocalPath().endswith('chrome_tests.gypi'): | |
| 56 continue | |
| 57 | |
| 58 for line_num, line in f.ChangedContents(): | |
| 59 m = re.search(r"'(.*\/content\/.*unittest.*)'", line) | |
| 60 if m: | |
| 61 problems.append(' %s' % m.group(1)) | |
| 62 | |
| 63 if not problems: | |
| 64 return [] | |
| 65 return [output_api.PresubmitPromptWarning( | |
| 66 'Unit tests located in content/ should be added to the ' + | |
| 67 'content_tests.gypi:content_unittests target.\n' + | |
| 68 '\n'.join(problems))] | |
|
Jói
2011/11/29 09:10:30
There is another constructor for a message followe
jochen (gone - plz use gerrit)
2011/11/29 13:01:11
Done.
| |
| 69 | |
| 70 def _CommonChecks(input_api, output_api): | |
| 71 """Checks common to both upload and commit.""" | |
| 72 results = [] | |
| 73 results.extend(_CheckNoContentUnitTestsInChrome(input_api, output_api)) | |
| 50 return results | 74 return results |
| 75 | |
| 76 def CheckChangeOnUpload(input_api, output_api): | |
| 77 results = [] | |
| 78 results.extend(_CommonChecks(input_api, output_api)) | |
| 79 results.extend(_CheckChangeLintsClean(input_api, output_api)) | |
| 80 return results | |
| 81 | |
| 82 def CheckChangeOnCommit(input_api, output_api): | |
| 83 results = [] | |
| 84 results.extend(_CommonChecks(input_api, output_api)) | |
| 85 return results | |
| OLD | NEW |