Changeset 254140 in webkit
- Timestamp:
- Jan 7, 2020 11:04:01 AM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r254130 r254140 1 2020-01-07 Basuke Suzuki <basuke.suzuki@sony.com> 2 3 check-webkit-style: bmalloc doesn't use config.h 4 https://bugs.webkit.org/show_bug.cgi?id=205840 5 6 Reviewed by Jonathan Bedard. 7 8 * Scripts/webkitpy/style/checkers/cpp.py: 9 (_IncludeState.check_next_include_order): 10 (check_include_line): 11 (check_has_config_header): 12 1 13 2020-01-07 youenn fablet <youenn@apple.com> 2 14 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py
r253641 r254140 138 138 139 139 140 _NO_CONFIG_H_PATH_PATTERNS = [ 141 '^Source/bmalloc/', 142 ] 143 140 144 def iteratively_replace_matches_with_char(pattern, char_replacement, s): 141 145 """Returns the string with replacement done. … … 295 299 return self._visited_soft_link_section 296 300 297 def check_next_include_order(self, header_type, filename, file_is_header, primary_header_exists ):301 def check_next_include_order(self, header_type, filename, file_is_header, primary_header_exists, has_config_header): 298 302 """Returns a non-empty error message if the next header is out of order. 299 303 … … 306 310 file_is_header: Whether the file that owns this _IncludeState is itself a header 307 311 primary_header_exists: Whether the primary header file actually exists on disk 312 has_config_header: Whether project uses config.h or not. 308 313 309 314 Returns: … … 335 340 if self._section >= self._PRIMARY_SECTION: 336 341 error_message = after_error_message 337 elif self._section < self._CONFIG_SECTION:342 elif has_config_header and self._section < self._CONFIG_SECTION: 338 343 error_message = before_error_message 339 344 self._section = self._PRIMARY_SECTION … … 3182 3187 header_type = _classify_include(filename, include, is_system, include_state) 3183 3188 primary_header_exists = _does_primary_header_exist(filename) 3189 has_config_header = check_has_config_header(filename) 3190 3184 3191 include_state.header_types[line_number] = header_type 3185 3192 … … 3196 3203 filename, 3197 3204 file_extension == "h", 3198 primary_header_exists) 3205 primary_header_exists, 3206 has_config_header) 3199 3207 3200 3208 # Check to make sure *SoftLink.h headers always appear last and never in a header. … … 3210 3218 error(line_number, 'build/include_order', 4, 3211 3219 'You should add a blank line after implementation file\'s own header.') 3212 if is_blank_line(previous_line):3220 if has_config_header and is_blank_line(previous_line): 3213 3221 error(line_number, 'build/include_order', 4, 3214 3222 'You should not add a blank line before implementation file\'s own header.') … … 3799 3807 file_path = file_path.replace(os.path.sep, '/') 3800 3808 return file_path in _AUTO_GENERATED_FILES 3809 3810 3811 def check_has_config_header(file_path): 3812 """Check if the module uses config.h""" 3813 file_path = file_path.replace(os.path.sep, '/') 3814 for pattern in _NO_CONFIG_H_PATH_PATTERNS: 3815 if re.match(pattern, file_path): 3816 return False 3817 return True 3801 3818 3802 3819 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
r253641 r254140 2948 2948 def test_check_next_include_order__no_config(self): 2949 2949 self.assertEqual('Header file should not contain WebCore config.h.', 2950 self.include_state.check_next_include_order(cpp_style._CONFIG_HEADER, 'Foo.h', True, True ))2950 self.include_state.check_next_include_order(cpp_style._CONFIG_HEADER, 'Foo.h', True, True, True)) 2951 2951 2952 2952 def test_check_next_include_order__no_self(self): 2953 2953 self.assertEqual('Header file should not contain itself.', 2954 self.include_state.check_next_include_order(cpp_style._PRIMARY_HEADER, 'Foo.h', True, True ))2954 self.include_state.check_next_include_order(cpp_style._PRIMARY_HEADER, 'Foo.h', True, True, True)) 2955 2955 # Test actual code to make sure that header types are correctly assigned. 2956 2956 self.assert_language_rules_check('Foo.h', … … 2964 2964 def test_check_next_include_order__likely_then_config(self): 2965 2965 self.assertEqual('Found header this file implements before WebCore config.h.', 2966 self.include_state.check_next_include_order(cpp_style._PRIMARY_HEADER, 'Foo.cpp', False, True ))2966 self.include_state.check_next_include_order(cpp_style._PRIMARY_HEADER, 'Foo.cpp', False, True, True)) 2967 2967 self.assertEqual('Found WebCore config.h after a header this file implements.', 2968 self.include_state.check_next_include_order(cpp_style._CONFIG_HEADER, 'Foo.cpp', False, True)) 2968 self.include_state.check_next_include_order(cpp_style._CONFIG_HEADER, 'Foo.cpp', False, True, True)) 2969 2970 def test_check_next_include_order__no_config_module(self): 2971 self.assertEqual('', 2972 self.include_state.check_next_include_order(cpp_style._PRIMARY_HEADER, 'Foo.cpp', False, True, False)) 2969 2973 2970 2974 def test_check_next_include_order__other_then_config(self): 2971 2975 self.assertEqual('Found other header before WebCore config.h.', 2972 self.include_state.check_next_include_order(cpp_style._OTHER_HEADER, 'Foo.cpp', False, True ))2976 self.include_state.check_next_include_order(cpp_style._OTHER_HEADER, 'Foo.cpp', False, True, True)) 2973 2977 self.assertEqual('Found WebCore config.h after other header.', 2974 self.include_state.check_next_include_order(cpp_style._CONFIG_HEADER, 'Foo.cpp', False, True ))2978 self.include_state.check_next_include_order(cpp_style._CONFIG_HEADER, 'Foo.cpp', False, True, True)) 2975 2979 2976 2980 def test_check_next_include_order__config_then_other_then_likely(self): 2977 self.assertEqual('', self.include_state.check_next_include_order(cpp_style._CONFIG_HEADER, 'Foo.cpp', False, True ))2981 self.assertEqual('', self.include_state.check_next_include_order(cpp_style._CONFIG_HEADER, 'Foo.cpp', False, True, True)) 2978 2982 self.assertEqual('Found other header before a header this file implements.', 2979 self.include_state.check_next_include_order(cpp_style._OTHER_HEADER, 'Foo.cpp', False, True ))2983 self.include_state.check_next_include_order(cpp_style._OTHER_HEADER, 'Foo.cpp', False, True, True)) 2980 2984 self.assertEqual('Found header this file implements after other header.', 2981 self.include_state.check_next_include_order(cpp_style._PRIMARY_HEADER, 'Foo.cpp', False, True ))2985 self.include_state.check_next_include_order(cpp_style._PRIMARY_HEADER, 'Foo.cpp', False, True, True)) 2982 2986 2983 2987 def test_check_alphabetical_include_order(self):
Note: See TracChangeset
for help on using the changeset viewer.