OLD | NEW |
1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
2 # | 2 # |
3 # Use of this source code is governed by a BSD-style license | 3 # Use of this source code is governed by a BSD-style license |
4 # that can be found in the LICENSE file in the root of the source | 4 # that can be found in the LICENSE file in the root of the source |
5 # tree. An additional intellectual property rights grant can be found | 5 # tree. An additional intellectual property rights grant can be found |
6 # in the file PATENTS. All contributing project authors may | 6 # in the file PATENTS. All contributing project authors may |
7 # be found in the AUTHORS file in the root of the source tree. | 7 # be found in the AUTHORS file in the root of the source tree. |
8 | 8 |
9 import json | 9 import json |
10 import os | 10 import os |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if not os.path.isdir(path): | 108 if not os.path.isdir(path): |
109 non_existing_paths.append(path) | 109 non_existing_paths.append(path) |
110 if non_existing_paths: | 110 if non_existing_paths: |
111 return [output_api.PresubmitError( | 111 return [output_api.PresubmitError( |
112 'Directories to native API headers have changed which has made the ' | 112 'Directories to native API headers have changed which has made the ' |
113 'list in PRESUBMIT.py outdated.\nPlease update it to the current ' | 113 'list in PRESUBMIT.py outdated.\nPlease update it to the current ' |
114 'location of our native APIs.', | 114 'location of our native APIs.', |
115 non_existing_paths)] | 115 non_existing_paths)] |
116 return [] | 116 return [] |
117 | 117 |
118 api_change_msg = """ | 118 API_CHANGE_MSG = """ |
119 You seem to be changing native API header files. Please make sure that you: | 119 You seem to be changing native API header files. Please make sure that you: |
120 1. Make compatible changes that don't break existing clients. Usually | 120 1. Make compatible changes that don't break existing clients. Usually |
121 this is done by keeping the existing method signatures unchanged. | 121 this is done by keeping the existing method signatures unchanged. |
122 2. Mark the old stuff as deprecated (see RTC_DEPRECATED macro). | 122 2. Mark the old stuff as deprecated (see RTC_DEPRECATED macro). |
123 3. Create a timeline and plan for when the deprecated stuff will be | 123 3. Create a timeline and plan for when the deprecated stuff will be |
124 removed. (The amount of time we give users to change their code | 124 removed. (The amount of time we give users to change their code |
125 should be informed by how much work it is for them. If they just | 125 should be informed by how much work it is for them. If they just |
126 need to replace one name with another or something equally | 126 need to replace one name with another or something equally |
127 simple, 1-2 weeks might be good; if they need to do serious work, | 127 simple, 1-2 weeks might be good; if they need to do serious work, |
128 up to 3 months may be called for.) | 128 up to 3 months may be called for.) |
129 4. Update/inform existing downstream code owners to stop using the | 129 4. Update/inform existing downstream code owners to stop using the |
130 deprecated stuff. (Send announcements to | 130 deprecated stuff. (Send announcements to |
131 discuss-webrtc@googlegroups.com and webrtc-users@google.com.) | 131 discuss-webrtc@googlegroups.com and webrtc-users@google.com.) |
132 5. Remove the deprecated stuff, once the agreed-upon amount of time | 132 5. Remove the deprecated stuff, once the agreed-upon amount of time |
133 has passed. | 133 has passed. |
134 Related files: | 134 Related files: |
135 """ | 135 """ |
136 | 136 |
137 def _CheckNativeApiHeaderChanges(input_api, output_api): | 137 def _CheckNativeApiHeaderChanges(input_api, output_api): |
138 """Checks to remind proper changing of native APIs.""" | 138 """Checks to remind proper changing of native APIs.""" |
139 files = [] | 139 files = [] |
140 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): | 140 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): |
141 if f.LocalPath().endswith('.h'): | 141 if f.LocalPath().endswith('.h'): |
142 for path in API_DIRS: | 142 for path in API_DIRS: |
143 if os.path.dirname(f.LocalPath()) == path: | 143 if os.path.dirname(f.LocalPath()) == path: |
144 files.append(f) | 144 files.append(f) |
145 | 145 |
146 if files: | 146 if files: |
147 return [output_api.PresubmitNotifyResult(api_change_msg, files)] | 147 return [output_api.PresubmitNotifyResult(API_CHANGE_MSG, files)] |
148 return [] | 148 return [] |
149 | 149 |
150 | 150 |
151 def _CheckNoIOStreamInHeaders(input_api, output_api): | 151 def _CheckNoIOStreamInHeaders(input_api, output_api): |
152 """Checks to make sure no .h files include <iostream>.""" | 152 """Checks to make sure no .h files include <iostream>.""" |
153 files = [] | 153 files = [] |
154 pattern = input_api.re.compile(r'^#include\s*<iostream>', | 154 pattern = input_api.re.compile(r'^#include\s*<iostream>', |
155 input_api.re.MULTILINE) | 155 input_api.re.MULTILINE) |
156 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): | 156 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): |
157 if not f.LocalPath().endswith('.h'): | 157 if not f.LocalPath().endswith('.h'): |
(...skipping 24 matching lines...) Expand all Loading... |
182 files.append(f) | 182 files.append(f) |
183 | 183 |
184 if files: | 184 if files: |
185 return [output_api.PresubmitError( | 185 return [output_api.PresubmitError( |
186 'Do not use #pragma once in header files.\n' | 186 'Do not use #pragma once in header files.\n' |
187 'See http://www.chromium.org/developers/coding-style#TOC-File-headers', | 187 'See http://www.chromium.org/developers/coding-style#TOC-File-headers', |
188 files)] | 188 files)] |
189 return [] | 189 return [] |
190 | 190 |
191 | 191 |
192 def _CheckNoFRIEND_TEST(input_api, output_api): | 192 def _CheckNoFRIEND_TEST(input_api, output_api): # pylint: disable=invalid-name |
193 """Make sure that gtest's FRIEND_TEST() macro is not used, the | 193 """Make sure that gtest's FRIEND_TEST() macro is not used, the |
194 FRIEND_TEST_ALL_PREFIXES() macro from testsupport/gtest_prod_util.h should be | 194 FRIEND_TEST_ALL_PREFIXES() macro from testsupport/gtest_prod_util.h should be |
195 used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes.""" | 195 used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes.""" |
196 problems = [] | 196 problems = [] |
197 | 197 |
198 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h')) | 198 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h')) |
199 for f in input_api.AffectedFiles(file_filter=file_filter): | 199 for f in input_api.AffectedFiles(file_filter=file_filter): |
200 for line_num, line in f.ChangedContents(): | 200 for line_num, line in f.ChangedContents(): |
201 if 'FRIEND_TEST(' in line: | 201 if 'FRIEND_TEST(' in line: |
202 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | 202 problems.append(' %s:%d' % (f.LocalPath(), line_num)) |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 file_filter=FilterFile, include_deletes=False): | 444 file_filter=FilterFile, include_deletes=False): |
445 parse_error = GetJSONParseError(input_api, | 445 parse_error = GetJSONParseError(input_api, |
446 affected_file.AbsoluteLocalPath()) | 446 affected_file.AbsoluteLocalPath()) |
447 if parse_error: | 447 if parse_error: |
448 results.append(output_api.PresubmitError('%s could not be parsed: %s' % | 448 results.append(output_api.PresubmitError('%s could not be parsed: %s' % |
449 (affected_file.LocalPath(), parse_error))) | 449 (affected_file.LocalPath(), parse_error))) |
450 return results | 450 return results |
451 | 451 |
452 | 452 |
453 def _RunPythonTests(input_api, output_api): | 453 def _RunPythonTests(input_api, output_api): |
454 def join(*args): | 454 def Join(*args): |
455 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) | 455 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) |
456 | 456 |
457 test_directories = [ | 457 test_directories = [ |
458 join('webrtc', 'tools', 'py_event_log_analyzer') | 458 Join('webrtc', 'tools', 'py_event_log_analyzer') |
459 ] + [ | 459 ] + [ |
460 root for root, _, files in os.walk(join('tools-webrtc')) | 460 root for root, _, files in os.walk(Join('tools-webrtc')) |
461 if any(f.endswith('_test.py') for f in files) | 461 if any(f.endswith('_test.py') for f in files) |
462 ] | 462 ] |
463 | 463 |
464 tests = [] | 464 tests = [] |
465 for directory in test_directories: | 465 for directory in test_directories: |
466 tests.extend( | 466 tests.extend( |
467 input_api.canned_checks.GetUnitTestsInDirectory( | 467 input_api.canned_checks.GetUnitTestsInDirectory( |
468 input_api, | 468 input_api, |
469 output_api, | 469 output_api, |
470 directory, | 470 directory, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 input_api, output_api)) | 560 input_api, output_api)) |
561 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 561 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
562 input_api, output_api)) | 562 input_api, output_api)) |
563 results.extend(_CheckChangeHasBugField(input_api, output_api)) | 563 results.extend(_CheckChangeHasBugField(input_api, output_api)) |
564 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 564 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
565 input_api, output_api)) | 565 input_api, output_api)) |
566 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 566 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
567 input_api, output_api, | 567 input_api, output_api, |
568 json_url='http://webrtc-status.appspot.com/current?format=json')) | 568 json_url='http://webrtc-status.appspot.com/current?format=json')) |
569 return results | 569 return results |
OLD | NEW |