Changeset 65308 in webkit
- Timestamp:
- Aug 13, 2010 1:54:53 AM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r65294 r65308 1 2010-08-13 Kenichi Ishibashi <bashi@google.com> 2 3 Reviewed by Shinichiro Hamaji. 4 5 Add test_expectations.txt syntax checker to check-webkit-style. 6 https://bugs.webkit.org/show_bug.cgi?id=43899 7 8 Just utilizing layout_tests/layout_package/test_expectations.py for checking 9 the syntax of test_expectations.txt. 10 This change also moves tab checking class from style/checkers/text.py to 11 style/checkers/common.py for sharing code. 12 13 * Scripts/webkitpy/layout_tests/layout_package/test_expectations.py: 14 * Scripts/webkitpy/style/checker.py: 15 * Scripts/webkitpy/style/checkers/common.py: 16 * Scripts/webkitpy/style/checkers/common_unittest.py: 17 * Scripts/webkitpy/style/checkers/test_expectations.py: Added. 18 * Scripts/webkitpy/style/checkers/test_expectations_unittest.py: Added. 19 * Scripts/webkitpy/style/checkers/text.py: 20 * Scripts/webkitpy/style_references.py: 21 1 22 2010-08-12 Jon Honeycutt <jhoneycutt@apple.com> 2 23 -
trunk/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
r57934 r65308 460 460 return ExpectationsJsonEncoder(separators=(',', ':')).encode( 461 461 self._all_expectations) 462 463 def get_non_fatal_errors(self): 464 return self._non_fatal_errors 462 465 463 466 def contains(self, test): -
trunk/WebKitTools/Scripts/webkitpy/style/checker.py
r62490 r65308 39 39 from checkers.cpp import CppChecker 40 40 from checkers.python import PythonChecker 41 from checkers.test_expectations import TestExpectationsChecker 41 42 from checkers.text import TextChecker 42 43 from error_handlers import DefaultStyleErrorHandler … … 235 236 # Take the union across all checkers. 236 237 categories = CommonCategories.union(CppChecker.categories) 238 categories = categories.union(TestExpectationsChecker.categories) 237 239 238 240 # FIXME: Consider adding all of the pep8 categories. Since they … … 400 402 # an exception to prevent files like "LayoutTests/ChangeLog" and 401 403 # "LayoutTests/ChangeLog-2009-06-16" from being skipped. 404 # Files like 'test_expectations.txt' and 'drt_expectations.txt' 405 # are also should not be skipped. 402 406 # 403 407 # FIXME: Figure out a good way to avoid having to add special logic 404 408 # for this special case. 405 if os.path.basename(file_path).startswith('ChangeLog'): 409 basename = os.path.basename(file_path) 410 if basename.startswith('ChangeLog'): 411 return False 412 elif basename == 'test_expectations.txt' or basename == 'drt_expectations.txt': 406 413 return False 407 414 for skipped_file in _SKIPPED_FILES_WITHOUT_WARNING: … … 443 450 checker = PythonChecker(file_path, handle_style_error) 444 451 elif file_type == FileType.TEXT: 445 checker = TextChecker(file_path, handle_style_error) 452 basename = os.path.basename(file_path) 453 if basename == 'test_expectations.txt' or basename == 'drt_expectations.txt': 454 checker = TestExpectationsChecker(file_path, handle_style_error) 455 else: 456 checker = TextChecker(file_path, handle_style_error) 446 457 else: 447 458 raise ValueError('Invalid file type "%(file_type)s": the only valid file types ' -
trunk/WebKitTools/Scripts/webkitpy/style/checkers/common.py
r58742 r65308 31 31 categories = set([ 32 32 "whitespace/carriage_return", 33 ])33 "whitespace/tab"]) 34 34 35 35 … … 56 56 57 57 return lines 58 59 60 class TabChecker(object): 61 62 """Supports checking for and handling tabs.""" 63 64 def __init__(self, file_path, handle_style_error): 65 self.file_path = file_path 66 self.handle_style_error = handle_style_error 67 68 def check(self, lines): 69 # FIXME: share with cpp_style. 70 for line_number, line in enumerate(lines): 71 if "\t" in line: 72 self.handle_style_error(line_number + 1, 73 "whitespace/tab", 5, 74 "Line contains tab character.") -
trunk/WebKitTools/Scripts/webkitpy/style/checkers/common_unittest.py
r58742 r65308 26 26 27 27 from common import CarriageReturnChecker 28 28 from common import TabChecker 29 29 30 30 # FIXME: The unit tests for the cpp, text, and common checkers should … … 93 93 ["line1", "line2", "line3"], 94 94 [2, 3]) 95 96 97 class TabCheckerTest(unittest.TestCase): 98 99 """Tests for TabChecker.""" 100 101 def assert_tab(self, input_lines, error_lines): 102 """Assert when the given lines contain tabs.""" 103 self._error_lines = [] 104 105 def style_error_handler(line_number, category, confidence, message): 106 self.assertEqual(category, 'whitespace/tab') 107 self.assertEqual(confidence, 5) 108 self.assertEqual(message, 'Line contains tab character.') 109 self._error_lines.append(line_number) 110 111 checker = TabChecker('', style_error_handler) 112 checker.check(input_lines) 113 self.assertEquals(self._error_lines, error_lines) 114 115 def test_notab(self): 116 self.assert_tab([''], []) 117 self.assert_tab(['foo', 'bar'], []) 118 119 def test_tab(self): 120 self.assert_tab(['\tfoo'], [1]) 121 self.assert_tab(['line1', '\tline2', 'line3\t'], [2, 3]) 122 123 if __name__ == '__main__': 124 unittest.main() -
trunk/WebKitTools/Scripts/webkitpy/style/checkers/text.py
r58742 r65308 30 30 """Checks WebKit style for text files.""" 31 31 32 from common import TabChecker 32 33 33 34 class TextChecker(object): … … 38 39 self.file_path = file_path 39 40 self.handle_style_error = handle_style_error 41 self._tab_checker = TabChecker(file_path, handle_style_error) 40 42 41 43 def check(self, lines): 42 lines = (["// adjust line numbers to make the first line 1."] + lines) 43 44 # FIXME: share with cpp_style. 45 for line_number, line in enumerate(lines): 46 if "\t" in line: 47 self.handle_style_error(line_number, 48 "whitespace/tab", 5, 49 "Line contains tab character.") 44 self._tab_checker.check(lines) 50 45 51 46 -
trunk/WebKitTools/Scripts/webkitpy/style_references.py
r63004 r65308 46 46 from webkitpy.common.system.logutils import configure_logging 47 47 from webkitpy.common.checkout.scm import detect_scm_system 48 from webkitpy.layout_tests import port 49 from webkitpy.layout_tests.layout_package import test_expectations 48 50 from webkitpy.thirdparty.autoinstalled import pep8 49 51
Note: See TracChangeset
for help on using the changeset viewer.