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 depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
9 """ | 9 """ |
10 | 10 |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 return results | 683 return results |
684 | 684 |
685 | 685 |
686 def _CheckIncludeOrderForScope(scope, input_api, file_path, changed_linenums): | 686 def _CheckIncludeOrderForScope(scope, input_api, file_path, changed_linenums): |
687 """Checks that the lines in scope occur in the right order. | 687 """Checks that the lines in scope occur in the right order. |
688 | 688 |
689 1. C system files in alphabetical order | 689 1. C system files in alphabetical order |
690 2. C++ system files in alphabetical order | 690 2. C++ system files in alphabetical order |
691 3. Project's .h files | 691 3. Project's .h files |
692 """ | 692 """ |
693 | |
694 c_system_include_pattern = input_api.re.compile(r'\s*#include <.*\.h>') | 693 c_system_include_pattern = input_api.re.compile(r'\s*#include <.*\.h>') |
695 cpp_system_include_pattern = input_api.re.compile(r'\s*#include <.*>') | 694 cpp_system_include_pattern = input_api.re.compile(r'\s*#include <.*>') |
696 custom_include_pattern = input_api.re.compile(r'\s*#include ".*') | 695 custom_include_pattern = input_api.re.compile(r'\s*#include ".*') |
697 | 696 |
698 C_SYSTEM_INCLUDES, CPP_SYSTEM_INCLUDES, CUSTOM_INCLUDES = range(3) | 697 C_SYSTEM_INCLUDES, CPP_SYSTEM_INCLUDES, CUSTOM_INCLUDES = range(3) |
699 | 698 |
700 state = C_SYSTEM_INCLUDES | 699 state = C_SYSTEM_INCLUDES |
701 | 700 |
702 previous_line = '' | 701 previous_line = '' |
703 previous_line_num = 0 | 702 previous_line_num = 0 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 # some/path/file.h, the corresponding including file can be some/path/file.cc, | 767 # some/path/file.h, the corresponding including file can be some/path/file.cc, |
769 # some/other/path/file.cc, some/path/file_platform.cc, some/path/file-suffix.h | 768 # some/other/path/file.cc, some/path/file_platform.cc, some/path/file-suffix.h |
770 # etc. It's also possible that no special first include exists. | 769 # etc. It's also possible that no special first include exists. |
771 # If the included file is some/path/file_platform.h the including file could | 770 # If the included file is some/path/file_platform.h the including file could |
772 # also be some/path/file_xxxtest_platform.h. | 771 # also be some/path/file_xxxtest_platform.h. |
773 including_file_base_name = test_file_tag_pattern.sub( | 772 including_file_base_name = test_file_tag_pattern.sub( |
774 '', input_api.os_path.basename(f.LocalPath())) | 773 '', input_api.os_path.basename(f.LocalPath())) |
775 | 774 |
776 for line in contents: | 775 for line in contents: |
777 line_num += 1 | 776 line_num += 1 |
| 777 if uncheckable_includes_pattern.match(line): |
| 778 continue |
778 if system_include_pattern.match(line): | 779 if system_include_pattern.match(line): |
779 # No special first include -> process the line again along with normal | 780 # No special first include -> process the line again along with normal |
780 # includes. | 781 # includes. |
781 line_num -= 1 | 782 line_num -= 1 |
782 break | 783 break |
783 match = custom_include_pattern.match(line) | 784 match = custom_include_pattern.match(line) |
784 if match: | 785 if match: |
785 match_dict = match.groupdict() | 786 match_dict = match.groupdict() |
786 header_basename = test_file_tag_pattern.sub( | 787 header_basename = test_file_tag_pattern.sub( |
787 '', input_api.os_path.basename(match_dict['FILE'])).replace('.h', '') | 788 '', input_api.os_path.basename(match_dict['FILE'])).replace('.h', '') |
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 for master in masters: | 1921 for master in masters: |
1921 try_config.setdefault(master, {}) | 1922 try_config.setdefault(master, {}) |
1922 for builder in masters[master]: | 1923 for builder in masters[master]: |
1923 # Do not trigger presubmit builders, since they're likely to fail | 1924 # Do not trigger presubmit builders, since they're likely to fail |
1924 # (e.g. OWNERS checks before finished code review), and we're | 1925 # (e.g. OWNERS checks before finished code review), and we're |
1925 # running local presubmit anyway. | 1926 # running local presubmit anyway. |
1926 if 'presubmit' not in builder: | 1927 if 'presubmit' not in builder: |
1927 try_config[master][builder] = ['defaulttests'] | 1928 try_config[master][builder] = ['defaulttests'] |
1928 | 1929 |
1929 return try_config | 1930 return try_config |
OLD | NEW |