Changeset 52232 in webkit
- Timestamp:
- Dec 16, 2009 9:30:45 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r52228 r52232 1 2009-12-16 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by David Levin. 4 5 check-webkit-style supports for TAB check against text files. 6 https://bugs.webkit.org/show_bug.cgi?id=32538 7 8 * Scripts/check-webkit-style: 9 Move process_patch() to style.py. 10 * Scripts/modules/cpp_style.py: 11 Add can_handle(). 12 * Scripts/modules/cpp_style_unittest.py: 13 Add tests for can_handle(). 14 * Scripts/modules/style.py: 15 Added. This is a front-end of cpp_style and text_style. It dispatches 16 files to an appropriate linter. 17 * Scripts/modules/text_style.py: 18 Added. This is a linter module for generic text files. It supports 19 only for TAB checking at this moment. 20 * Scripts/modules/text_style_unittest.py: 21 Added. Tests for text_style.py. 22 * Scripts/run-webkit-unittests: 23 Add text_style_unittest. 24 1 25 2009-12-16 Eric Seidel <eric@webkit.org> 2 26 -
trunk/WebKitTools/Scripts/check-webkit-style
r52189 r52232 29 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 30 31 """Does WebKit-lint on C/C++ files.31 """Does WebKit-lint on C/C++ or text files. 32 32 33 33 The goal of this script is to identify places in the code that *may* … … 48 48 49 49 import modules.cpp_style as cpp_style 50 from modules.diff_parser import DiffParser 50 import modules.style as style 51 51 from modules.scm import detect_scm_system 52 52 53 53 54 # FIXME: Avoid cpp_style dependency. 54 55 cpp_style._USAGE = """ 55 56 Syntax: %(program_name)s [--verbose=#] [--git-commit=<SingleCommit>] [--output=vs7] … … 116 117 117 118 118 def process_patch(patch_string):119 """Does lint on a single patch.119 def main(): 120 style.use_webkit_styles() 120 121 121 Args: 122 patch_string: A string of a patch. 123 """ 124 patch = DiffParser(patch_string.splitlines()) 125 for filename, diff in patch.files.iteritems(): 126 file_extension = os.path.splitext(filename)[1] 127 128 if file_extension in ['.cpp', '.c', '.h']: 129 line_numbers = set() 130 131 def error_for_patch(filename, line_number, category, confidence, message): 132 """Wrapper function of cpp_style.error for patches. 133 134 This function outputs errors only if the line number 135 corresponds to lines which are modified or added. 136 """ 137 if not line_numbers: 138 for line in diff.lines: 139 # When deleted line is not set, it means that 140 # the line is newly added. 141 if not line[0]: 142 line_numbers.add(line[1]) 143 144 if line_number in line_numbers: 145 cpp_style.error(filename, line_number, category, confidence, message) 146 147 cpp_style.process_file(filename, error=error_for_patch) 148 149 150 def main(): 151 cpp_style._DEFAULT_FILTER_RULES = cpp_style._WEBKIT_FILTER_RULES 152 153 (files, flags) = cpp_style.parse_arguments(sys.argv[1:], ["git-commit="], 154 display_help=True) 122 (files, flags) = style.parse_arguments(sys.argv[1:], ["git-commit="], 123 display_help=True) 155 124 156 125 # Change stderr to write with replacement characters so we don't die … … 168 137 if files: 169 138 for filename in files: 170 cpp_style.process_file(filename)139 style.process_file(filename) 171 140 172 141 else: … … 184 153 else: 185 154 patch = scm.create_patch() 186 process_patch(patch)155 style.process_patch(patch) 187 156 188 sys.stderr.write('Total errors found: %d\n' % cpp_style.error_count())189 sys.exit( cpp_style.error_count() > 0)157 sys.stderr.write('Total errors found: %d\n' % style.error_count()) 158 sys.exit(style.error_count() > 0) 190 159 191 160 -
trunk/WebKitTools/Scripts/modules/cpp_style.py
r52189 r52232 3159 3159 # When reading from stdin, the extension is unknown, so no cpp_style tests 3160 3160 # should rely on the extension. 3161 if (filename != '-' and file_extension != 'h' and file_extension != 'cpp' 3162 and file_extension != 'c'): 3161 if (filename != '-' and not can_handle(filename)): 3163 3162 sys.stderr.write('Ignoring %s; not a .cpp, .c or .h file\n' % filename) 3164 3163 else: … … 3262 3261 3263 3262 return (filenames, additional_flag_values) 3263 3264 3265 def can_handle(filename): 3266 """Checks if this module supports for the specified file type. 3267 3268 Args: 3269 filename: A filename. It may contain directory names. 3270 """ 3271 return os.path.splitext(filename)[1] in ('.h', '.cpp', '.c') -
trunk/WebKitTools/Scripts/modules/cpp_style_unittest.py
r52189 r52232 3718 3718 3719 3719 3720 def test_can_handle(self): 3721 """Tests for cpp_style.can_handle().""" 3722 self.assert_(not cpp_style.can_handle('')) 3723 self.assert_(cpp_style.can_handle('foo.h')) 3724 self.assert_(not cpp_style.can_handle('foo.hpp')) 3725 self.assert_(cpp_style.can_handle('foo.c')) 3726 self.assert_(cpp_style.can_handle('foo.cpp')) 3727 self.assert_(not cpp_style.can_handle('foo.cc')) 3728 self.assert_(not cpp_style.can_handle('foo.cxx')) 3729 self.assert_(not cpp_style.can_handle('foo.C')) 3730 self.assert_(not cpp_style.can_handle('foo.mm')) 3731 self.assert_(not cpp_style.can_handle('-')) 3732 3733 3720 3734 def tearDown(): 3721 3735 """A global check to make sure all error-categories have been tested. -
trunk/WebKitTools/Scripts/run-webkit-unittests
r52142 r52232 44 44 from modules.logging_unittest import * 45 45 from modules.multicommandtool_unittest import * 46 from modules.text_style_unittest import * 46 47 from modules.webkitport_unittest import * 47 48 from modules.workqueue_unittest import *
Note: See TracChangeset
for help on using the changeset viewer.