OLD | NEW |
---|---|
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
M-A Ruel
2011/08/26 13:12:45
sorry but can you update it to 2011? Since the CQ
Denis Lagno
2011/08/26 13:31:33
Done.
| |
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 """Generic presubmit checks that can be reused by other presubmit checks.""" | 5 """Generic presubmit checks that can be reused by other presubmit checks.""" |
6 | 6 |
7 | 7 |
8 ### Description checks | 8 ### Description checks |
9 | 9 |
10 def CheckChangeHasTestField(input_api, output_api): | 10 def CheckChangeHasTestField(input_api, output_api): |
11 """Requires that the changelist have a TEST= field.""" | 11 """Requires that the changelist have a TEST= field.""" |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 else: | 821 else: |
822 res_type = output_api.PresubmitNotifyResult | 822 res_type = output_api.PresubmitNotifyResult |
823 return [ res_type('|const NSClass*| is wrong, see ' + | 823 return [ res_type('|const NSClass*| is wrong, see ' + |
824 'http://dev.chromium.org/developers/clang-mac', | 824 'http://dev.chromium.org/developers/clang-mac', |
825 files) ] | 825 files) ] |
826 return [] | 826 return [] |
827 | 827 |
828 | 828 |
829 def _CheckSingletonInHeaders(input_api, output_api, source_file_filter): | 829 def _CheckSingletonInHeaders(input_api, output_api, source_file_filter): |
830 """Checks to make sure no header files have |Singleton<|.""" | 830 """Checks to make sure no header files have |Singleton<|.""" |
831 pattern = input_api.re.compile(r'Singleton<') | 831 pattern = input_api.re.compile(r'Singleton\s*<') |
832 | |
833 def strip_cpp_eol_comment(line): | |
834 pattern = input_api.re.compile(r'//.*$') | |
835 return pattern.sub('', line) | |
M-A Ruel
2011/08/26 13:12:45
I'm not sure it's useful; using "input_api.re.sub(
Denis Lagno
2011/08/26 13:31:33
Done.
| |
836 | |
832 files = [] | 837 files = [] |
833 for f in input_api.AffectedSourceFiles(source_file_filter): | 838 for f in input_api.AffectedSourceFiles(source_file_filter): |
834 if (f.LocalPath().endswith('.h') or f.LocalPath().endswith('.hxx') or | 839 if (f.LocalPath().endswith('.h') or f.LocalPath().endswith('.hxx') or |
835 f.LocalPath().endswith('.hpp') or f.LocalPath().endswith('.inl')): | 840 f.LocalPath().endswith('.hpp') or f.LocalPath().endswith('.inl')): |
836 contents = input_api.ReadFile(f) | 841 contents = input_api.ReadFile(f) |
837 if pattern.search(contents): | 842 for line in contents.splitlines(False): |
838 files.append(f) | 843 if pattern.search(strip_cpp_eol_comment(line)): |
844 files.append(f) | |
845 break | |
839 | 846 |
840 if files: | 847 if files: |
841 return [ output_api.PresubmitError( | 848 return [ output_api.PresubmitError( |
842 'Found Singleton<T> in the following header files.\n' + | 849 'Found Singleton<T> in the following header files.\n' + |
843 'Please move them to an appropriate source file so that the ' + | 850 'Please move them to an appropriate source file so that the ' + |
844 'template gets instantiated in a single compilation unit.', | 851 'template gets instantiated in a single compilation unit.', |
845 files) ] | 852 files) ] |
846 return [] | 853 return [] |
847 | 854 |
848 | 855 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
936 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 943 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
937 input_api, output_api)) | 944 input_api, output_api)) |
938 snapshot("checking license") | 945 snapshot("checking license") |
939 results.extend(input_api.canned_checks.CheckLicense( | 946 results.extend(input_api.canned_checks.CheckLicense( |
940 input_api, output_api, license_header, source_file_filter=sources)) | 947 input_api, output_api, license_header, source_file_filter=sources)) |
941 snapshot("checking was uploaded") | 948 snapshot("checking was uploaded") |
942 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 949 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
943 input_api, output_api)) | 950 input_api, output_api)) |
944 snapshot("done") | 951 snapshot("done") |
945 return results | 952 return results |
OLD | NEW |