Changeset 252440 in webkit
- Timestamp:
- Nov 13, 2019, 5:04:35 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 32 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/test-webkitpy-python3 (modified) (1 diff)
-
Scripts/webkitpy/port/builders.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/changelog.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/changelog_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/cmake.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/cmake_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/common_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/contributors.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/cpp.py (modified) (9 diffs)
-
Scripts/webkitpy/style/checkers/cpp_unittest.py (modified) (4 diffs)
-
Scripts/webkitpy/style/checkers/js.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/js_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/jsonchecker.py (modified) (2 diffs)
-
Scripts/webkitpy/style/checkers/jsonchecker_unittest.py (modified) (2 diffs)
-
Scripts/webkitpy/style/checkers/jstest_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/messagesin.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/messagesin_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/png_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/python.py (modified) (4 diffs)
-
Scripts/webkitpy/style/checkers/python_unittest.py (modified) (3 diffs)
-
Scripts/webkitpy/style/checkers/python_unittest_falsepositives.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/python_unittest_input.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/test_expectations.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/test_expectations_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/text.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/text_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/watchlist_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/xcodeproj_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/checkers/xml_unittest.py (modified) (1 diff)
-
Scripts/webkitpy/style/optparser.py (modified) (1 diff)
-
Scripts/webkitpy/thirdparty/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r252438 r252440 1 2019-11-13 Jonathan Bedard <jbedard@apple.com> 2 3 Python 3: Add support in webkitpy.style.checkers 4 https://bugs.webkit.org/show_bug.cgi?id=203761 5 6 Rubber-stamped by Stephanie Lewis. 7 8 * Scripts/test-webkitpy-python3: Add webkitpy.style.checkers. 9 * Scripts/webkitpy/port/builders.py: 10 (all_port_names): Convert map to a list before concatenating. 11 * Scripts/webkitpy/style/checkers/changelog.py: Use explicit imports. 12 * Scripts/webkitpy/style/checkers/changelog_unittest.py: Ditto. 13 * Scripts/webkitpy/style/checkers/cmake.py: Ditto. 14 * Scripts/webkitpy/style/checkers/cmake_unittest.py: Ditto. 15 * Scripts/webkitpy/style/checkers/common_unittest.py: Ditto. 16 * Scripts/webkitpy/style/checkers/contributors.py: Ditto. 17 * Scripts/webkitpy/style/checkers/cpp.py: 18 (Position): Add rich comparison functions. 19 (check_for_copyright): Use range instead of xrange. 20 (detect_functions): Ditto. 21 (check_language): Use r-string. 22 (check_for_include_what_you_use): Use range instead of xrange. 23 (_process_lines): Convert iterator to list, use range instead of xrange. 24 * Scripts/webkitpy/style/checkers/cpp_unittest.py: 25 (CppStyleTest): Be explicit about bytes vs strings. 26 * Scripts/webkitpy/style/checkers/js.py: Use explicit imports. 27 * Scripts/webkitpy/style/checkers/js_unittest.py: Ditto. 28 * Scripts/webkitpy/style/checkers/jsonchecker.py: Ditto. 29 (JSONFeaturesChecker.check): 30 * Scripts/webkitpy/style/checkers/jsonchecker_unittest.py: Ditto. 31 (JSONCheckerTest.test_conflict_marker): Differentiate between Python 2 and 3 32 json parsers. 33 * Scripts/webkitpy/style/checkers/jstest_unittest.py: Use explicit imports. 34 * Scripts/webkitpy/style/checkers/messagesin.py: Ditto. 35 * Scripts/webkitpy/style/checkers/messagesin_unittest.py: Ditto. 36 * Scripts/webkitpy/style/checkers/png_unittest.py: Ditto. 37 * Scripts/webkitpy/style/checkers/python.py: 38 (PythonChecker.check): Only run pylint in Python 2. 39 (PythonChecker._check_pylint): Use r string. 40 (Pylinter.run): Surpress logging from Pylint. 41 * Scripts/webkitpy/style/checkers/python_unittest.py: Use explicit imports. 42 (PythonCheckerTest.test_check): Add FIXME for running pylint in Python 3. 43 * Scripts/webkitpy/style/checkers/python_unittest_falsepositives.py: 44 * Scripts/webkitpy/style/checkers/python_unittest_input.py: 45 * Scripts/webkitpy/style/checkers/test_expectations.py: Use explicit imports. 46 * Scripts/webkitpy/style/checkers/test_expectations_unittest.py: Ditto. 47 * Scripts/webkitpy/style/checkers/text.py: Ditto. 48 * Scripts/webkitpy/style/checkers/text_unittest.py: Ditto. 49 * Scripts/webkitpy/style/checkers/watchlist_unittest.py: Ditto. 50 * Scripts/webkitpy/style/checkers/xcodeproj_unittest.py: Ditto. 51 * Scripts/webkitpy/style/checkers/xml_unittest.py: Ditto. 52 * Scripts/webkitpy/thirdparty/__init__.py: 53 (AutoinstallImportHook._install_pep8): Update pep8 version. 54 1 55 2019-11-13 Jer Noble <jer.noble@apple.com> 2 56 -
trunk/Tools/Scripts/test-webkitpy-python3
r251961 r252440 39 39 'webkitpy.port', 40 40 'webkitpy.results', 41 'webkitpy.style.checkers', 41 42 'webkitpy.xcode', 42 43 ] -
trunk/Tools/Scripts/webkitpy/port/builders.py
r225274 r252440 103 103 104 104 def all_port_names(): 105 return sorted(set( map(lambda x: x["port_name"], _exact_matches.values()) + _ports_without_builders))105 return sorted(set(list(map(lambda x: x["port_name"], _exact_matches.values())) + _ports_without_builders)) 106 106 107 107 -
trunk/Tools/Scripts/webkitpy/style/checkers/changelog.py
r207146 r252440 24 24 """Checks WebKit style for ChangeLog files.""" 25 25 26 from common import TabChecker, match, search, searchIgnorecase27 26 from sys import maxsize 28 27 from webkitpy.common.checkout.changelog import parse_bug_id_from_changelog 28 from webkitpy.style.checkers.common import TabChecker, match, search, searchIgnorecase 29 29 30 30 -
trunk/Tools/Scripts/webkitpy/style/checkers/changelog_unittest.py
r223177 r252440 24 24 """Unit test for changelog.py.""" 25 25 26 import changelog27 26 import unittest 27 28 from webkitpy.style.checkers import changelog 28 29 29 30 -
trunk/Tools/Scripts/webkitpy/style/checkers/cmake.py
r185065 r252440 26 26 """Supports checking WebKit style in cmake files.(.cmake, CMakeLists.txt)""" 27 27 28 from common import TabChecker, match, search, searchIgnorecase28 from webkitpy.style.checkers.common import TabChecker, match, search, searchIgnorecase 29 29 30 30 -
trunk/Tools/Scripts/webkitpy/style/checkers/cmake_unittest.py
r185065 r252440 25 25 import unittest 26 26 27 from cmake import CMakeChecker27 from webkitpy.style.checkers.cmake import CMakeChecker 28 28 29 29 -
trunk/Tools/Scripts/webkitpy/style/checkers/common_unittest.py
r202362 r252440 25 25 import unittest 26 26 27 from common import CarriageReturnChecker28 from common import TabChecker27 from webkitpy.style.checkers.common import CarriageReturnChecker 28 from webkitpy.style.checkers.common import TabChecker 29 29 30 30 -
trunk/Tools/Scripts/webkitpy/style/checkers/contributors.py
r225698 r252440 27 27 import re 28 28 from sets import Set 29 from jsonchecker import JSONChecker29 from webkitpy.style.checkers.jsonchecker import JSONChecker 30 30 from webkitpy.common.config.committers import CommitterList 31 31 from webkitpy.common.system.filesystem import FileSystem -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py
r252433 r252440 46 46 import unicodedata 47 47 48 from common import match, search, sub, subn48 from webkitpy.style.checkers.common import match, search, sub, subn 49 49 from webkitpy.common.memoized import memoized 50 from webkitpy.common.unicode_compatibility import unicode 50 51 51 52 # The key to use to provide a class to fake loading a header file. … … 367 368 368 369 def __cmp__(self, other): 369 return self.row.__cmp__(other.row) or self.column.__cmp__(other.column) 370 return (self.row - other.row) or (self.column - other.column) 371 372 def __eq__(self, other): 373 return self.__cmp__(other) == 0 374 375 def __ne__(self, other): 376 return self.__cmp__(other) != 0 377 378 def __lt__(self, other): 379 return self.__cmp__(other) < 0 380 381 def __le__(self, other): 382 return self.__cmp__(other) <= 0 383 384 def __gt__(self, other): 385 return self.__cmp__(other) > 0 386 387 def __ge__(self, other): 388 return self.__cmp__(other) >= 0 370 389 371 390 … … 898 917 # We'll say it should occur by line 10. Don't forget there's a 899 918 # dummy line at the front. 900 for line in xrange(1, min(len(lines), 11)):919 for line in range(1, min(len(lines), 11)): 901 920 if re.search(r'Copyright', lines[line], re.I): 902 921 break … … 1597 1616 1598 1617 joined_line = '' 1599 for start_line_number in xrange(line_number, clean_lines.num_lines()):1618 for start_line_number in range(line_number, clean_lines.num_lines()): 1600 1619 start_line = clean_lines.elided[start_line_number] 1601 1620 joined_line += ' ' + start_line.lstrip() … … 3370 3389 previous_closing_angle_bracket_index = -1 3371 3390 closing_angle_bracket_index = 9 # Used if only one pair of angle brackets. 3372 for i in xrange(10, len(match_line) - 1):3391 for i in range(10, len(match_line) - 1): 3373 3392 if match_line[i] == '<': 3374 3393 nested_angle_bracket_count += 1 … … 3383 3402 break 3384 3403 3385 matched = re.compile( '^\s*SOFT_LINK_(PRIVATE_)?FRAMEWORK.*\((\S+)\)').search(line)3404 matched = re.compile(r'^\s*SOFT_LINK_(PRIVATE_)?FRAMEWORK.*\((\S+)\)').search(line) 3386 3405 if matched: 3387 3406 framework_name = matched.group(2) … … 3884 3903 # Example of required: { '<functional>': (1219, 'less<>') } 3885 3904 3886 for line_number in xrange(clean_lines.num_lines()):3905 for line_number in range(clean_lines.num_lines()): 3887 3906 line = clean_lines.elided[line_number] 3888 3907 if not line or line[0] == '#': … … 3927 3946 # include_state is modified during iteration, so we iterate over a copy of 3928 3947 # the keys. 3929 for header in include_state.keys(): # NOLINT3948 for header in list(include_state.keys()): # NOLINT 3930 3949 (same_module, common_path) = files_belong_to_same_module(abs_filename, header) 3931 3950 fullpath = common_path + header … … 4052 4071 enum_state = _EnumState() 4053 4072 asm_state = _InlineASMState() 4054 for line in xrange(clean_lines.num_lines()):4073 for line in range(clean_lines.num_lines()): 4055 4074 process_line(filename, file_extension, clean_lines, line, 4056 4075 include_state, function_state, class_state, file_state, -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
r252433 r252440 41 41 import re 42 42 import unittest 43 import cpp as cpp_style 44 from cpp import CppChecker 45 from ..filter import FilterConfiguration 43 from webkitpy.common.unicode_compatibility import decode_if_necessary 44 from webkitpy.style.checkers import cpp as cpp_style 45 from webkitpy.style.checkers.cpp import CppChecker 46 from webkitpy.style.filter import FilterConfiguration 46 47 47 48 … … 2448 2449 error_collector = ErrorCollector(self.assertTrue) 2449 2450 self.process_file_data('foo.cpp', 'cpp', 2450 unicode(raw_bytes, 'utf8','replace').split('\n'),2451 decode_if_necessary(raw_bytes, encoding='utf8', errors='replace').split('\n'), 2451 2452 error_collector) 2452 2453 # The warning appears only once. … … 2458 2459 ' [readability/utf8] [5]')) 2459 2460 2460 do_test(self, 'Hello world\n', False)2461 do_test(self, '\xe9\x8e\xbd\n', False)2462 do_test(self, '\xe9x\x8e\xbd\n', True)2461 do_test(self, b'Hello world\n', False) 2462 do_test(self, b'\xe9\x8e\xbd\n', False) 2463 do_test(self, b'\xe9x\x8e\xbd\n', True) 2463 2464 # This is the encoding of the replacement character itself (which 2464 2465 # you can see by evaluating codecs.getencoder('utf8')(u'\ufffd')). 2465 do_test(self, '\xef\xbf\xbd\n', True)2466 do_test(self, b'\xef\xbf\xbd\n', True) 2466 2467 2467 2468 def test_is_blank_line(self): … … 2787 2788 random.choice(types)] 2788 2789 # remove None 2789 other_decl_specs = filter(lambda x: x is not None, other_decl_specs)2790 other_decl_specs = list(filter(lambda x: x is not None, other_decl_specs)) 2790 2791 2791 2792 # shuffle -
trunk/Tools/Scripts/webkitpy/style/checkers/js.py
r202362 r252440 31 31 """ 32 32 33 from common import TabChecker34 33 import re 34 from webkitpy.style.checkers.common import TabChecker 35 35 36 36 -
trunk/Tools/Scripts/webkitpy/style/checkers/js_unittest.py
r174136 r252440 32 32 import unittest 33 33 34 from js import JSChecker34 from webkitpy.style.checkers.js import JSChecker 35 35 36 36 -
trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py
r240251 r252440 25 25 import json 26 26 import re 27 from sets import Set28 27 29 28 … … 71 70 return 72 71 73 specification_name_set = Set()72 specification_name_set = set() 74 73 if 'specification' in features_definition: 75 74 previous_specification_name = '' -
trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker_unittest.py
r174136 r252440 23 23 """Unit test for jsonchecker.py.""" 24 24 25 import sys 25 26 import unittest 26 27 27 import jsonchecker28 from webkitpy.style.checkers import jsonchecker 28 29 29 30 … … 82 83 83 84 def test_conflict_marker(self): 84 self.assert_error(0, 'json/syntax', '<<<<<<< HEAD\n{\n}\n') 85 # Python 2 0 indexes json parser errors, Python 3 1 indexes them 86 self.assert_error(1 if sys.version_info > (3, 0) else 0, 'json/syntax', '<<<<<<< HEAD\n{\n}\n') 85 87 86 88 def test_single_quote(self): -
trunk/Tools/Scripts/webkitpy/style/checkers/jstest_unittest.py
r216110 r252440 26 26 import unittest 27 27 28 from jstest import map_functions_to_dict28 from webkitpy.style.checkers.jstest import map_functions_to_dict 29 29 30 30 -
trunk/Tools/Scripts/webkitpy/style/checkers/messagesin.py
r160093 r252440 26 26 27 27 import re 28 from common import TabChecker28 from webkitpy.style.checkers.common import TabChecker 29 29 30 30 -
trunk/Tools/Scripts/webkitpy/style/checkers/messagesin_unittest.py
r174136 r252440 27 27 import unittest 28 28 29 from messagesin import MessagesInChecker29 from webkitpy.style.checkers.messagesin import MessagesInChecker 30 30 31 31 -
trunk/Tools/Scripts/webkitpy/style/checkers/png_unittest.py
r174136 r252440 26 26 import unittest 27 27 28 from png import PNGChecker28 from webkitpy.style.checkers.png import PNGChecker 29 29 from webkitpy.common.system.filesystem_mock import MockFileSystem 30 30 from webkitpy.common.system.systemhost_mock import MockSystemHost -
trunk/Tools/Scripts/webkitpy/style/checkers/python.py
r247538 r252440 25 25 26 26 import re 27 from StringIO import StringIO 27 import sys 28 28 29 29 from webkitpy.common.system.filesystem import FileSystem 30 from webkitpy.common.unicode_compatibility import StringIO 31 from webkitpy.common.system.outputcapture import OutputCaptureScope 30 32 from webkitpy.common.webkit_finder import WebKitFinder 31 33 from webkitpy.thirdparty.autoinstalled import pep8 32 from webkitpy.thirdparty.autoinstalled.pylint import lint33 from webkitpy.thirdparty.autoinstalled.pylint.reporters.text import ParseableTextReporter34 34 35 35 … … 42 42 def check(self, lines): 43 43 self._check_pep8(lines) 44 self._check_pylint(lines) 44 # FIXME: https://bugs.webkit.org/show_bug.cgi?id=204133 45 # Pylint can't live happily in python 2 and 3 world, we need to pick one 46 if sys.version_info < (3, 0): 47 self._check_pylint(lines) 45 48 46 49 def _check_pep8(self, lines): … … 72 75 output = pylinter.run(['-E', self._file_path]) 73 76 74 lint_regex = re.compile( '([^:]+):([^:]+): \[([^]]+)\] (.*)')77 lint_regex = re.compile(r'([^:]+):([^:]+): \[([^]]+)\] (.*)') 75 78 for error in output.getvalue().splitlines(): 76 79 match_obj = lint_regex.match(error) 77 assert(match_obj) 80 if not match_obj: 81 continue 78 82 line_number = int(match_obj.group(2)) 79 83 category_and_method = match_obj.group(3).split(', ') … … 105 109 def run(self, argv): 106 110 output = _FilteredStringIO(self.FALSE_POSITIVES) 107 lint.Run(['--rcfile', self._pylintrc] + argv, reporter=ParseableTextReporter(output=output), exit=False) 111 with OutputCaptureScope(): 112 from webkitpy.thirdparty.autoinstalled.pylint import lint 113 from webkitpy.thirdparty.autoinstalled.pylint.reporters.text import ParseableTextReporter 114 lint.Run(['--rcfile', self._pylintrc] + argv, reporter=ParseableTextReporter(output=output), exit=False) 108 115 return output 109 116 -
trunk/Tools/Scripts/webkitpy/style/checkers/python_unittest.py
r174136 r252440 24 24 25 25 import os 26 import sys 26 27 import unittest 27 28 28 from python import PythonChecker29 from webkitpy.style.checkers.python import PythonChecker 29 30 30 31 … … 47 48 errors = [] 48 49 49 def _mock_handle_style_error(line_number, category, confidence, 50 message): 50 def _mock_handle_style_error(line_number, category, confidence, message): 51 51 error = (line_number, category, confidence, message) 52 52 errors.append(error) … … 58 58 checker.check(lines=[]) 59 59 60 self.assertEqual(errors, [ 61 (4, "pep8/W291", 5, "trailing whitespace"), 62 (4, "pylint/E0602", 5, "Undefined variable 'error'"), 63 ]) 60 # FIXME: https://bugs.webkit.org/show_bug.cgi?id=204133 61 expected_errors = [(4, "pep8/W291", 5, "trailing whitespace")] 62 if sys.version_info < (3, 0): 63 expected_errors.append((4, "pylint/E0602", 5, "Undefined variable 'error'")) 64 65 self.assertEqual(errors, expected_errors) 64 66 65 67 def test_pylint_false_positives(self): -
trunk/Tools/Scripts/webkitpy/style/checkers/python_unittest_falsepositives.py
r152639 r252440 6 6 7 7 def test_popen(proc): 8 p = subprocess.Popen(proc, stdout=subprocess.PIPE, 9 stderr=subprocess.STDOUT) 8 p = subprocess.Popen( 9 proc, 10 stdout=subprocess.PIPE, 11 stderr=subprocess.STDOUT, 12 ) 10 13 tmp1 = p.poll 11 14 tmp2 = p.returncode -
trunk/Tools/Scripts/webkitpy/style/checkers/python_unittest_input.py
r134309 r252440 2 2 # problems, one that will generate a PEP-8 warning for trailing whitespace 3 3 # and one that will generate a pylint error for an undefined variable. 4 print error()4 print(error()) -
trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py
r220158 r252440 35 35 import sys 36 36 37 from common import TabChecker38 37 from webkitpy.common.host import Host 39 38 from webkitpy.layout_tests.models import test_expectations 39 from webkitpy.style.checkers.common import TabChecker 40 40 from webkitpy.style.error_handlers import DefaultStyleErrorHandler 41 41 -
trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations_unittest.py
r215758 r252440 31 31 import unittest 32 32 33 from test_expectations import TestExpectationsChecker34 33 from webkitpy.common.host_mock import MockHost 34 from webkitpy.style.checkers.test_expectations import TestExpectationsChecker 35 35 36 36 -
trunk/Tools/Scripts/webkitpy/style/checkers/text.py
r202362 r252440 30 30 """Checks WebKit style for text files.""" 31 31 32 from common import TabChecker32 from webkitpy.style.checkers.common import TabChecker 33 33 34 34 -
trunk/Tools/Scripts/webkitpy/style/checkers/text_unittest.py
r202362 r252440 31 31 import unittest 32 32 33 import text as text_style34 from text import TextChecker33 from webkitpy.style.checkers import text as text_style 34 from webkitpy.style.checkers.text import TextChecker 35 35 36 36 -
trunk/Tools/Scripts/webkitpy/style/checkers/watchlist_unittest.py
r174136 r252440 34 34 import unittest 35 35 36 37 import watchlist 36 from webkitpy.style.checkers import watchlist 38 37 39 38 -
trunk/Tools/Scripts/webkitpy/style/checkers/xcodeproj_unittest.py
r237566 r252440 25 25 26 26 import unittest 27 import xcodeproj27 from webkitpy.style.checkers import xcodeproj 28 28 29 29 -
trunk/Tools/Scripts/webkitpy/style/checkers/xml_unittest.py
r174136 r252440 24 24 25 25 import unittest 26 import xml26 from webkitpy.style.checkers import xml 27 27 28 28 -
trunk/Tools/Scripts/webkitpy/style/optparser.py
r225733 r252440 28 28 import sys 29 29 30 from filter import validate_filter_rules30 from webkitpy.style.filter import validate_filter_rules 31 31 # This module should not import anything from checker.py. 32 32 -
trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py
r252358 r252440 153 153 154 154 def _install_pep8(self): 155 self._install("https://files.pythonhosted.org/packages/ source/p/pep8/pep8-0.5.0.tar.gz",156 "pep8- 0.5.0/pep8.py")155 self._install("https://files.pythonhosted.org/packages/01/a0/64ba19519db49e4094d82599412a9660dee8c26a7addbbb1bf17927ceefe/pep8-1.7.1.tar.gz", 156 "pep8-1.7.1/pep8.py") 157 157 def _install_pycodestyle(self): 158 158 self._install("https://files.pythonhosted.org/packages/source/p/pycodestyle/pycodestyle-2.5.0.tar.gz",
Note:
See TracChangeset
for help on using the changeset viewer.