Changeset 254140 in webkit


Ignore:
Timestamp:
Jan 7, 2020 11:04:01 AM (4 years ago)
Author:
basuke.suzuki@sony.com
Message:

check-webkit-style: bmalloc doesn't use config.h
https://bugs.webkit.org/show_bug.cgi?id=205840

Reviewed by Jonathan Bedard.

  • Scripts/webkitpy/style/checkers/cpp.py:

(_IncludeState.check_next_include_order):
(check_include_line):
(check_has_config_header):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r254130 r254140  
     12020-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
    1132020-01-07  youenn fablet  <youenn@apple.com>
    214
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r253641 r254140  
    138138
    139139
     140_NO_CONFIG_H_PATH_PATTERNS = [
     141    '^Source/bmalloc/',
     142]
     143
    140144def iteratively_replace_matches_with_char(pattern, char_replacement, s):
    141145    """Returns the string with replacement done.
     
    295299        return self._visited_soft_link_section
    296300
    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):
    298302        """Returns a non-empty error message if the next header is out of order.
    299303
     
    306310          file_is_header: Whether the file that owns this _IncludeState is itself a header
    307311          primary_header_exists: Whether the primary header file actually exists on disk
     312          has_config_header: Whether project uses config.h or not.
    308313
    309314        Returns:
     
    335340            if self._section >= self._PRIMARY_SECTION:
    336341                error_message = after_error_message
    337             elif self._section < self._CONFIG_SECTION:
     342            elif has_config_header and self._section < self._CONFIG_SECTION:
    338343                error_message = before_error_message
    339344            self._section = self._PRIMARY_SECTION
     
    31823187    header_type = _classify_include(filename, include, is_system, include_state)
    31833188    primary_header_exists = _does_primary_header_exist(filename)
     3189    has_config_header = check_has_config_header(filename)
     3190
    31843191    include_state.header_types[line_number] = header_type
    31853192
     
    31963203                                                           filename,
    31973204                                                           file_extension == "h",
    3198                                                            primary_header_exists)
     3205                                                           primary_header_exists,
     3206                                                           has_config_header)
    31993207
    32003208    # Check to make sure *SoftLink.h headers always appear last and never in a header.
     
    32103218            error(line_number, 'build/include_order', 4,
    32113219                '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):
    32133221            error(line_number, 'build/include_order', 4,
    32143222                'You should not add a blank line before implementation file\'s own header.')
     
    37993807    file_path = file_path.replace(os.path.sep, '/')
    38003808    return file_path in _AUTO_GENERATED_FILES
     3809
     3810
     3811def 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
    38013818
    38023819
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

    r253641 r254140  
    29482948    def test_check_next_include_order__no_config(self):
    29492949        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))
    29512951
    29522952    def test_check_next_include_order__no_self(self):
    29532953        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))
    29552955        # Test actual code to make sure that header types are correctly assigned.
    29562956        self.assert_language_rules_check('Foo.h',
     
    29642964    def test_check_next_include_order__likely_then_config(self):
    29652965        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))
    29672967        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))
    29692973
    29702974    def test_check_next_include_order__other_then_config(self):
    29712975        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))
    29732977        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))
    29752979
    29762980    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))
    29782982        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))
    29802984        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))
    29822986
    29832987    def test_check_alphabetical_include_order(self):
Note: See TracChangeset for help on using the changeset viewer.