Chromium Code Reviews| 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 _CheckNoUNIT_TESTInSourceFiles(input_api, output_api): | |
| 173 """Checks to make sure no source files use UNIT_TEST.""" | |
|
kwiberg-webrtc
2017/02/20 08:44:46
Either this doc string or the error message below
| |
| 174 problems = [] | |
| 175 for f in input_api.AffectedFiles(): | |
| 176 if not f.LocalPath().endswith(('.cc', '.mm')): | |
|
kwiberg-webrtc
2017/02/20 08:44:46
It would seem safer to have a whitelist of file ty
| |
| 177 continue | |
| 178 | |
| 179 for line_num, line in f.ChangedContents(): | |
| 180 if 'UNIT_TEST ' in line or line.endswith('UNIT_TEST'): | |
|
kwiberg-webrtc
2017/02/20 08:44:46
Use re to search the line for "\bUNIT_TEST\b"? Tha
| |
| 181 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | |
| 182 | |
| 183 if not problems: | |
| 184 return [] | |
| 185 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' + | |
| 186 '\n'.join(problems))] | |
| 187 | |
| 188 | |
| 172 def _CheckNoFRIEND_TEST(input_api, output_api): | 189 def _CheckNoFRIEND_TEST(input_api, output_api): |
| 173 """Make sure that gtest's FRIEND_TEST() macro is not used, the | 190 """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 | 191 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.""" | 192 used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes.""" |
| 176 problems = [] | 193 problems = [] |
| 177 | 194 |
| 178 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h')) | 195 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h')) |
| 179 for f in input_api.AffectedFiles(file_filter=file_filter): | 196 for f in input_api.AffectedFiles(file_filter=file_filter): |
| 180 for line_num, line in f.ChangedContents(): | 197 for line_num, line in f.ChangedContents(): |
| 181 if 'FRIEND_TEST(' in line: | 198 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( | 524 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( |
| 508 input_api, output_api)) | 525 input_api, output_api)) |
| 509 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( | 526 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( |
| 510 input_api, output_api)) | 527 input_api, output_api)) |
| 511 results.extend(input_api.canned_checks.CheckAuthorizedAuthor( | 528 results.extend(input_api.canned_checks.CheckAuthorizedAuthor( |
| 512 input_api, output_api)) | 529 input_api, output_api)) |
| 513 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( | 530 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( |
| 514 input_api, output_api)) | 531 input_api, output_api)) |
| 515 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) | 532 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) |
| 516 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 533 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
| 534 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) | |
| 517 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) | 535 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) |
| 518 results.extend(_CheckGnChanges(input_api, output_api)) | 536 results.extend(_CheckGnChanges(input_api, output_api)) |
| 519 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 537 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
| 520 results.extend(_CheckJSONParseErrors(input_api, output_api)) | 538 results.extend(_CheckJSONParseErrors(input_api, output_api)) |
| 521 results.extend(_RunPythonTests(input_api, output_api)) | 539 results.extend(_RunPythonTests(input_api, output_api)) |
| 522 return results | 540 return results |
| 523 | 541 |
| 524 | 542 |
| 525 def CheckChangeOnUpload(input_api, output_api): | 543 def CheckChangeOnUpload(input_api, output_api): |
| 526 results = [] | 544 results = [] |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 539 input_api, output_api)) | 557 input_api, output_api)) |
| 540 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 558 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
| 541 input_api, output_api)) | 559 input_api, output_api)) |
| 542 results.extend(_CheckChangeHasBugField(input_api, output_api)) | 560 results.extend(_CheckChangeHasBugField(input_api, output_api)) |
| 543 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 561 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
| 544 input_api, output_api)) | 562 input_api, output_api)) |
| 545 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 563 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
| 546 input_api, output_api, | 564 input_api, output_api, |
| 547 json_url='http://webrtc-status.appspot.com/current?format=json')) | 565 json_url='http://webrtc-status.appspot.com/current?format=json')) |
| 548 return results | 566 return results |
| OLD | NEW |