OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Top-level presubmit script for Chromium. | 5 """Top-level presubmit script for Chromium. |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
8 for more details about the presubmit API built into gcl. | 8 for more details about the presubmit API built into gcl. |
9 """ | 9 """ |
10 | 10 |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 if line_num in changed_linenums or previous_line_num in changed_linenums: | 552 if line_num in changed_linenums or previous_line_num in changed_linenums: |
553 warnings.append(' %s:%d' % (file_path, line_num)) | 553 warnings.append(' %s:%d' % (file_path, line_num)) |
554 return warnings | 554 return warnings |
555 | 555 |
556 | 556 |
557 def _CheckIncludeOrderInFile(input_api, f, is_source, changed_linenums): | 557 def _CheckIncludeOrderInFile(input_api, f, is_source, changed_linenums): |
558 """Checks the #include order for the given file f.""" | 558 """Checks the #include order for the given file f.""" |
559 | 559 |
560 system_include_pattern = input_api.re.compile(r'\s*#include \<.*') | 560 system_include_pattern = input_api.re.compile(r'\s*#include \<.*') |
561 custom_include_pattern = input_api.re.compile(r'\s*#include "(?P<FILE>.*)"') | 561 custom_include_pattern = input_api.re.compile(r'\s*#include "(?P<FILE>.*)"') |
562 if_pattern = input_api.re.compile(r'\s*#if.*') | 562 if_pattern = input_api.re.compile(r'\s*#\s*(if|elif|else|endif).*') |
563 endif_pattern = input_api.re.compile(r'\s*#endif.*') | |
564 | 563 |
565 contents = f.NewContents() | 564 contents = f.NewContents() |
566 warnings = [] | 565 warnings = [] |
567 line_num = 0 | 566 line_num = 0 |
568 | 567 |
569 # Handle the special first include for source files. If the header file is | 568 # Handle the special first include for source files. If the header file is |
570 # some/path/file.h, the corresponding source file can be some/path/file.cc, | 569 # some/path/file.h, the corresponding source file can be some/path/file.cc, |
571 # some/other/path/file.cc, some/path/file_platform.cc etc. It's also possible | 570 # some/other/path/file.cc, some/path/file_platform.cc etc. It's also possible |
572 # that no special first include exists. | 571 # that no special first include exists. |
573 if is_source: | 572 if is_source: |
(...skipping 13 matching lines...) Expand all Loading... |
587 # No special first include -> process the line again along with normal | 586 # No special first include -> process the line again along with normal |
588 # includes. | 587 # includes. |
589 line_num -= 1 | 588 line_num -= 1 |
590 break | 589 break |
591 | 590 |
592 # Split into scopes: Each region between #if and #endif is its own scope. | 591 # Split into scopes: Each region between #if and #endif is its own scope. |
593 scopes = [] | 592 scopes = [] |
594 current_scope = [] | 593 current_scope = [] |
595 for line in contents[line_num:]: | 594 for line in contents[line_num:]: |
596 line_num += 1 | 595 line_num += 1 |
597 if if_pattern.match(line) or endif_pattern.match(line): | 596 if if_pattern.match(line): |
598 scopes.append(current_scope) | 597 scopes.append(current_scope) |
599 current_scope = [] | 598 current_scope = [] |
600 elif (system_include_pattern.match(line) or | 599 elif (system_include_pattern.match(line) or |
601 custom_include_pattern.match(line)): | 600 custom_include_pattern.match(line)): |
602 current_scope.append((line_num, line)) | 601 current_scope.append((line_num, line)) |
603 scopes.append(current_scope) | 602 scopes.append(current_scope) |
604 | 603 |
605 for scope in scopes: | 604 for scope in scopes: |
606 warnings.extend(_CheckIncludeOrderForScope(scope, input_api, f.LocalPath(), | 605 warnings.extend(_CheckIncludeOrderForScope(scope, input_api, f.LocalPath(), |
607 changed_linenums)) | 606 changed_linenums)) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 646 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
648 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) | 647 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) |
649 results.extend(_CheckNoNewWStrings(input_api, output_api)) | 648 results.extend(_CheckNoNewWStrings(input_api, output_api)) |
650 results.extend(_CheckNoDEPSGIT(input_api, output_api)) | 649 results.extend(_CheckNoDEPSGIT(input_api, output_api)) |
651 results.extend(_CheckNoBannedFunctions(input_api, output_api)) | 650 results.extend(_CheckNoBannedFunctions(input_api, output_api)) |
652 results.extend(_CheckNoPragmaOnce(input_api, output_api)) | 651 results.extend(_CheckNoPragmaOnce(input_api, output_api)) |
653 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api)) | 652 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api)) |
654 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 653 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
655 results.extend(_CheckFilePermissions(input_api, output_api)) | 654 results.extend(_CheckFilePermissions(input_api, output_api)) |
656 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api)) | 655 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api)) |
657 # Causes a problem with content/renderer/render_view_impl.cc | 656 results.extend(_CheckIncludeOrder(input_api, output_api)) |
658 #results.extend(_CheckIncludeOrder(input_api, output_api)) | |
659 | 657 |
660 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 658 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
661 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 659 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
662 input_api, output_api, | 660 input_api, output_api, |
663 input_api.PresubmitLocalPath(), | 661 input_api.PresubmitLocalPath(), |
664 whitelist=[r'.+_test\.py$'])) | 662 whitelist=[r'.+_test\.py$'])) |
665 return results | 663 return results |
666 | 664 |
667 | 665 |
668 def _CheckSubversionConfig(input_api, output_api): | 666 def _CheckSubversionConfig(input_api, output_api): |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 | 800 |
803 # Match things like path/aura/file.cc and path/file_aura.cc. | 801 # Match things like path/aura/file.cc and path/file_aura.cc. |
804 # Same for ash and chromeos. | 802 # Same for ash and chromeos. |
805 if any(re.search('[/_](ash|aura)', f) for f in files): | 803 if any(re.search('[/_](ash|aura)', f) for f in files): |
806 trybots += ['linux_chromeos_clang:compile', 'win_aura', | 804 trybots += ['linux_chromeos_clang:compile', 'win_aura', |
807 'linux_chromeos_asan'] | 805 'linux_chromeos_asan'] |
808 elif any(re.search('[/_]chromeos', f) for f in files): | 806 elif any(re.search('[/_]chromeos', f) for f in files): |
809 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan'] | 807 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan'] |
810 | 808 |
811 return trybots | 809 return trybots |
OLD | NEW |