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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 if warning_descriptions: | 416 if warning_descriptions: |
417 results.append(output_api.PresubmitPromptOrNotify( | 417 results.append(output_api.PresubmitPromptOrNotify( |
418 'You added one or more #includes of files that are temporarily\n' | 418 'You added one or more #includes of files that are temporarily\n' |
419 'allowed but being removed. Can you avoid introducing the\n' | 419 'allowed but being removed. Can you avoid introducing the\n' |
420 '#include? See relevant DEPS file(s) for details and contacts.\n' | 420 '#include? See relevant DEPS file(s) for details and contacts.\n' |
421 'See https://cs.chromium.org/chromium/src/buildtools/checkdeps/ for ' | 421 'See https://cs.chromium.org/chromium/src/buildtools/checkdeps/ for ' |
422 'more details about checkdeps.', | 422 'more details about checkdeps.', |
423 warning_descriptions)) | 423 warning_descriptions)) |
424 return results | 424 return results |
425 | 425 |
426 def _CheckCommitMessageBugEntry(input_api, output_api): | |
427 """Check that bug entries are well-formed in commit message.""" | |
428 bogus_bug_msg = ( | |
429 'Bogus BUG entry: %s. Please specify the issue tracker prefix and the ' | |
430 'issue number, separated by a colon, e.g. webrtc:123 or chromium:12345.') | |
431 results = [] | |
432 for bug in (input_api.change.BUG or '').split(','): | |
433 bug = bug.strip() | |
434 if bug.lower() == 'none': | |
435 continue | |
436 if ':' not in bug: | |
437 try: | |
438 if int(bug) > 100000: | |
439 # Rough indicator for current chromium bugs. | |
440 prefix_guess = 'chromium' | |
441 else: | |
442 prefix_guess = 'webrtc' | |
443 results.append('BUG entry requires issue tracker prefix, e.g. %s:%s' % | |
444 (prefix_guess, bug)) | |
445 except ValueError: | |
446 results.append(bogus_bug_msg % bug) | |
447 elif not re.match(r'\w+:\d+', bug): | |
448 results.append(bogus_bug_msg % bug) | |
449 return [output_api.PresubmitError(r) for r in results] | |
450 | |
426 def _CheckChangeHasBugField(input_api, output_api): | 451 def _CheckChangeHasBugField(input_api, output_api): |
427 """Requires that the changelist have a BUG= field. | 452 """Requires that the changelist have a BUG= field. |
428 | 453 |
429 This check is stricter than the one in depot_tools/presubmit_canned_checks.py | 454 This check is stricter than the one in depot_tools/presubmit_canned_checks.py |
430 since it fails the presubmit if the BUG= field is missing or doesn't contain | 455 since it fails the presubmit if the BUG= field is missing or doesn't contain |
431 a bug reference. | 456 a bug reference. |
432 """ | 457 """ |
433 if input_api.change.BUG: | 458 if input_api.change.BUG: |
434 return [] | 459 return [] |
435 else: | 460 else: |
(...skipping 25 matching lines...) Expand all Loading... | |
461 if parse_error: | 486 if parse_error: |
462 results.append(output_api.PresubmitError('%s could not be parsed: %s' % | 487 results.append(output_api.PresubmitError('%s could not be parsed: %s' % |
463 (affected_file.LocalPath(), parse_error))) | 488 (affected_file.LocalPath(), parse_error))) |
464 return results | 489 return results |
465 | 490 |
466 | 491 |
467 def _RunPythonTests(input_api, output_api): | 492 def _RunPythonTests(input_api, output_api): |
468 def Join(*args): | 493 def Join(*args): |
469 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) | 494 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) |
470 | 495 |
471 test_directories = [ | 496 test_directories = [ |
kjellander_webrtc
2017/09/06 18:42:08
You need to add the root directory here in order t
| |
472 Join('webrtc', 'rtc_tools', 'py_event_log_analyzer'), | 497 Join('webrtc', 'rtc_tools', 'py_event_log_analyzer'), |
473 Join('webrtc', 'rtc_tools'), | 498 Join('webrtc', 'rtc_tools'), |
474 Join('webrtc', 'audio', 'test', 'unittests'), | 499 Join('webrtc', 'audio', 'test', 'unittests'), |
475 ] + [ | 500 ] + [ |
476 root for root, _, files in os.walk(Join('tools_webrtc')) | 501 root for root, _, files in os.walk(Join('tools_webrtc')) |
477 if any(f.endswith('_test.py') for f in files) | 502 if any(f.endswith('_test.py') for f in files) |
478 ] | 503 ] |
479 | 504 |
480 tests = [] | 505 tests = [] |
481 for directory in test_directories: | 506 for directory in test_directories: |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 def CheckChangeOnCommit(input_api, output_api): | 615 def CheckChangeOnCommit(input_api, output_api): |
591 results = [] | 616 results = [] |
592 results.extend(_CommonChecks(input_api, output_api)) | 617 results.extend(_CommonChecks(input_api, output_api)) |
593 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api)) | 618 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api)) |
594 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) | 619 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) |
595 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 620 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
596 input_api, output_api)) | 621 input_api, output_api)) |
597 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 622 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
598 input_api, output_api)) | 623 input_api, output_api)) |
599 results.extend(_CheckChangeHasBugField(input_api, output_api)) | 624 results.extend(_CheckChangeHasBugField(input_api, output_api)) |
625 results.extend(_CheckCommitMessageBugEntry(input_api, output_api)) | |
600 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 626 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
601 input_api, output_api, | 627 input_api, output_api, |
602 json_url='http://webrtc-status.appspot.com/current?format=json')) | 628 json_url='http://webrtc-status.appspot.com/current?format=json')) |
603 return results | 629 return results |
604 | 630 |
605 | 631 |
606 def _CheckOrphanHeaders(input_api, output_api): | 632 def _CheckOrphanHeaders(input_api, output_api): |
607 # We need to wait until we have an input_api object and use this | 633 # We need to wait until we have an input_api object and use this |
608 # roundabout construct to import prebubmit_checks_lib because this file is | 634 # roundabout construct to import prebubmit_checks_lib because this file is |
609 # eval-ed and thus doesn't have __file__. | 635 # eval-ed and thus doesn't have __file__. |
(...skipping 29 matching lines...) Expand all Loading... | |
639 results = [] | 665 results = [] |
640 source_file_filter = lambda x: input_api.FilterSourceFile( | 666 source_file_filter = lambda x: input_api.FilterSourceFile( |
641 x, white_list=(r'.+\.proto$',)) | 667 x, white_list=(r'.+\.proto$',)) |
642 for f in input_api.AffectedSourceFiles(source_file_filter): | 668 for f in input_api.AffectedSourceFiles(source_file_filter): |
643 file_path = f.LocalPath() | 669 file_path = f.LocalPath() |
644 with open(file_path) as f: | 670 with open(file_path) as f: |
645 lines = f.readlines() | 671 lines = f.readlines() |
646 if lines[-1] != '\n' or lines[-2] == '\n': | 672 if lines[-1] != '\n' or lines[-2] == '\n': |
647 results.append(output_api.PresubmitError(error_msg.format(file_path))) | 673 results.append(output_api.PresubmitError(error_msg.format(file_path))) |
648 return results | 674 return results |
OLD | NEW |