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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 if len(files): | 163 if len(files): |
164 return [output_api.PresubmitError( | 164 return [output_api.PresubmitError( |
165 'Do not #include <iostream> in header files, since it inserts static ' + | 165 'Do not #include <iostream> in header files, since it inserts static ' + |
166 'initialization into every file including the header. Instead, ' + | 166 'initialization into every file including the header. Instead, ' + |
167 '#include <ostream>. See http://crbug.com/94794', | 167 '#include <ostream>. See http://crbug.com/94794', |
168 files)] | 168 files)] |
169 return [] | 169 return [] |
170 | 170 |
171 | 171 |
| 172 def _CheckNoPragmaOnce(input_api, output_api): |
| 173 """Make sure that banned functions are not used.""" |
| 174 files = [] |
| 175 pattern = input_api.re.compile(r'^#pragma\s+once', |
| 176 input_api.re.MULTILINE) |
| 177 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): |
| 178 if not f.LocalPath().endswith('.h'): |
| 179 continue |
| 180 contents = input_api.ReadFile(f) |
| 181 if pattern.search(contents): |
| 182 files.append(f) |
| 183 |
| 184 if files: |
| 185 return [output_api.PresubmitError( |
| 186 'Do not use #pragma once in header files.\n' |
| 187 'See http://www.chromium.org/developers/coding-style#TOC-File-headers', |
| 188 files)] |
| 189 return [] |
| 190 |
| 191 |
172 def _CheckNoFRIEND_TEST(input_api, output_api): | 192 def _CheckNoFRIEND_TEST(input_api, output_api): |
173 """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 |
174 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 |
175 used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes.""" | 195 used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes.""" |
176 problems = [] | 196 problems = [] |
177 | 197 |
178 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h')) | 198 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h')) |
179 for f in input_api.AffectedFiles(file_filter=file_filter): | 199 for f in input_api.AffectedFiles(file_filter=file_filter): |
180 for line_num, line in f.ChangedContents(): | 200 for line_num, line in f.ChangedContents(): |
181 if 'FRIEND_TEST(' in line: | 201 if 'FRIEND_TEST(' in line: |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( | 527 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( |
508 input_api, output_api)) | 528 input_api, output_api)) |
509 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( | 529 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( |
510 input_api, output_api)) | 530 input_api, output_api)) |
511 results.extend(input_api.canned_checks.CheckAuthorizedAuthor( | 531 results.extend(input_api.canned_checks.CheckAuthorizedAuthor( |
512 input_api, output_api)) | 532 input_api, output_api)) |
513 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( | 533 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( |
514 input_api, output_api)) | 534 input_api, output_api)) |
515 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) | 535 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) |
516 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 536 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
| 537 results.extend(_CheckNoPragmaOnce(input_api, output_api)) |
517 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) | 538 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) |
518 results.extend(_CheckGnChanges(input_api, output_api)) | 539 results.extend(_CheckGnChanges(input_api, output_api)) |
519 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 540 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
520 results.extend(_CheckJSONParseErrors(input_api, output_api)) | 541 results.extend(_CheckJSONParseErrors(input_api, output_api)) |
521 results.extend(_RunPythonTests(input_api, output_api)) | 542 results.extend(_RunPythonTests(input_api, output_api)) |
522 return results | 543 return results |
523 | 544 |
524 | 545 |
525 def CheckChangeOnUpload(input_api, output_api): | 546 def CheckChangeOnUpload(input_api, output_api): |
526 results = [] | 547 results = [] |
(...skipping 12 matching lines...) Expand all Loading... |
539 input_api, output_api)) | 560 input_api, output_api)) |
540 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 561 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
541 input_api, output_api)) | 562 input_api, output_api)) |
542 results.extend(_CheckChangeHasBugField(input_api, output_api)) | 563 results.extend(_CheckChangeHasBugField(input_api, output_api)) |
543 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 564 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
544 input_api, output_api)) | 565 input_api, output_api)) |
545 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 566 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
546 input_api, output_api, | 567 input_api, output_api, |
547 json_url='http://webrtc-status.appspot.com/current?format=json')) | 568 json_url='http://webrtc-status.appspot.com/current?format=json')) |
548 return results | 569 return results |
OLD | NEW |