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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 for directory in test_directories: | 466 for directory in test_directories: |
467 tests.extend( | 467 tests.extend( |
468 input_api.canned_checks.GetUnitTestsInDirectory( | 468 input_api.canned_checks.GetUnitTestsInDirectory( |
469 input_api, | 469 input_api, |
470 output_api, | 470 output_api, |
471 directory, | 471 directory, |
472 whitelist=[r'.+_test\.py$'])) | 472 whitelist=[r'.+_test\.py$'])) |
473 return input_api.RunTests(tests, parallel=True) | 473 return input_api.RunTests(tests, parallel=True) |
474 | 474 |
475 | 475 |
| 476 def _CheckUsageOfGoogleProtobufNamespace(input_api, output_api): |
| 477 """Checks that the namespace google::protobuf has not been used.""" |
| 478 files = [] |
| 479 pattern = input_api.re.compile(r'google::protobuf') |
| 480 proto_utils_path = os.path.join('webrtc', 'base', 'protobuf_utils.h') |
| 481 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): |
| 482 if f.LocalPath() in [proto_utils_path, 'PRESUBMIT.py']: |
| 483 continue |
| 484 contents = input_api.ReadFile(f) |
| 485 if pattern.search(contents): |
| 486 files.append(f) |
| 487 |
| 488 if files: |
| 489 return [output_api.PresubmitError( |
| 490 'Please avoid to use namespace `google::protobuf` directly.\n' |
| 491 'Add a using directive in `%s` and include that header instead.' |
| 492 % proto_utils_path, files)] |
| 493 return [] |
| 494 |
| 495 |
476 def _CommonChecks(input_api, output_api): | 496 def _CommonChecks(input_api, output_api): |
477 """Checks common to both upload and commit.""" | 497 """Checks common to both upload and commit.""" |
478 results = [] | 498 results = [] |
479 # Filter out files that are in objc or ios dirs from being cpplint-ed since | 499 # Filter out files that are in objc or ios dirs from being cpplint-ed since |
480 # they do not follow C++ lint rules. | 500 # they do not follow C++ lint rules. |
481 black_list = input_api.DEFAULT_BLACK_LIST + ( | 501 black_list = input_api.DEFAULT_BLACK_LIST + ( |
482 r".*\bobjc[\\\/].*", | 502 r".*\bobjc[\\\/].*", |
483 r".*objc\.[hcm]+$", | 503 r".*objc\.[hcm]+$", |
484 r"webrtc\/build\/ios\/SDK\/.*", | 504 r"webrtc\/build\/ios\/SDK\/.*", |
485 ) | 505 ) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( | 554 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( |
535 input_api, output_api)) | 555 input_api, output_api)) |
536 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) | 556 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) |
537 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 557 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
538 results.extend(_CheckNoPragmaOnce(input_api, output_api)) | 558 results.extend(_CheckNoPragmaOnce(input_api, output_api)) |
539 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) | 559 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) |
540 results.extend(_CheckGnChanges(input_api, output_api)) | 560 results.extend(_CheckGnChanges(input_api, output_api)) |
541 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 561 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
542 results.extend(_CheckJSONParseErrors(input_api, output_api)) | 562 results.extend(_CheckJSONParseErrors(input_api, output_api)) |
543 results.extend(_RunPythonTests(input_api, output_api)) | 563 results.extend(_RunPythonTests(input_api, output_api)) |
| 564 results.extend(_CheckUsageOfGoogleProtobufNamespace(input_api, output_api)) |
544 return results | 565 return results |
545 | 566 |
546 | 567 |
547 def CheckChangeOnUpload(input_api, output_api): | 568 def CheckChangeOnUpload(input_api, output_api): |
548 results = [] | 569 results = [] |
549 results.extend(_CommonChecks(input_api, output_api)) | 570 results.extend(_CommonChecks(input_api, output_api)) |
550 results.extend( | 571 results.extend( |
551 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) | 572 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) |
552 return results | 573 return results |
553 | 574 |
554 | 575 |
555 def CheckChangeOnCommit(input_api, output_api): | 576 def CheckChangeOnCommit(input_api, output_api): |
556 results = [] | 577 results = [] |
557 results.extend(_CommonChecks(input_api, output_api)) | 578 results.extend(_CommonChecks(input_api, output_api)) |
558 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api)) | 579 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api)) |
559 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) | 580 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) |
560 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 581 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
561 input_api, output_api)) | 582 input_api, output_api)) |
562 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 583 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
563 input_api, output_api)) | 584 input_api, output_api)) |
564 results.extend(_CheckChangeHasBugField(input_api, output_api)) | 585 results.extend(_CheckChangeHasBugField(input_api, output_api)) |
565 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 586 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
566 input_api, output_api)) | 587 input_api, output_api)) |
567 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 588 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
568 input_api, output_api, | 589 input_api, output_api, |
569 json_url='http://webrtc-status.appspot.com/current?format=json')) | 590 json_url='http://webrtc-status.appspot.com/current?format=json')) |
570 return results | 591 return results |
OLD | NEW |