Changeset 86165 in webkit


Ignore:
Timestamp:
May 10, 2011 10:28:08 AM (13 years ago)
Author:
levin@chromium.org
Message:

2011-05-10 David Levin <levin@chromium.org>

Reviewed by Shinichiro Hamaji.

check-webkit-style shouldn't filter the errors using the modified lines for the xml and test expectations checkers.
https://bugs.webkit.org/show_bug.cgi?id=60466

  • Scripts/webkitpy/style/checker.py: (unrelated) style fix.
  • Scripts/webkitpy/style/checker_unittest.py: Remove the file_path check since that property was removed.
  • Scripts/webkitpy/style/checkers/test_expectations.py: Turn off the line filtering for errors.
  • Scripts/webkitpy/style/checkers/test_expectations_unittest.py: Add testing to verify that the line filtering is turned off.
  • Scripts/webkitpy/style/checkers/xml.py: Turn off the line filtering for errors and remove the unused file_path parameter.
  • Scripts/webkitpy/style/checkers/xml_unittest.py: Add testing to verify that the line filtering is turned off (and fix test_no_error).
  • Scripts/webkitpy/style/error_handlers.py: Added a way to turn off the filtering of errors based on the lines changed in the patch.
  • Scripts/webkitpy/style/error_handlers_unittest.py: Added a test for turning off the filtering.
Location:
trunk/Tools
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r86157 r86165  
     12011-05-10  David Levin  <levin@chromium.org>
     2
     3        Reviewed by Shinichiro Hamaji.
     4
     5        check-webkit-style shouldn't filter the errors using the modified lines for the xml and test expectations checkers.
     6        https://bugs.webkit.org/show_bug.cgi?id=60466
     7
     8        * Scripts/webkitpy/style/checker.py: (unrelated) style fix.
     9        * Scripts/webkitpy/style/checker_unittest.py: Remove the file_path check since
     10          that property was removed.
     11        * Scripts/webkitpy/style/checkers/test_expectations.py: Turn off the line
     12          filtering for errors.
     13        * Scripts/webkitpy/style/checkers/test_expectations_unittest.py: Add testing to
     14          verify that the line filtering is turned off.
     15        * Scripts/webkitpy/style/checkers/xml.py: Turn off the line filtering for errors
     16          and remove the unused file_path parameter.
     17        * Scripts/webkitpy/style/checkers/xml_unittest.py: Add testing to verify that the
     18          line filtering is turned off (and fix test_no_error).
     19        * Scripts/webkitpy/style/error_handlers.py: Added a way to turn off the filtering
     20          of errors based on the lines changed in the patch.
     21        * Scripts/webkitpy/style/error_handlers_unittest.py: Added a test for turning off
     22          the filtering.
     23
    1242011-05-10  Adam Roben  <aroben@apple.com>
    225
  • trunk/Tools/Scripts/webkitpy/style/checker.py

    r85062 r86165  
    766766        min_confidence = self._configuration.min_confidence
    767767        checker = self._dispatcher.dispatch(file_path,
    768                                                       style_error_handler,
    769                                                       min_confidence)
     768                                            style_error_handler,
     769                                            min_confidence)
    770770
    771771        if checker is None:
  • trunk/Tools/Scripts/webkitpy/style/checker_unittest.py

    r85062 r86165  
    548548        self.assert_checker_xml(file_path)
    549549        checker = self.dispatch(file_path)
    550         self.assertEquals(checker.file_path, file_path)
    551         self.assertEquals(checker.handle_style_error,
     550        self.assertEquals(checker._handle_style_error,
    552551                          self.mock_handle_style_error)
    553552
  • trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py

    r85875 r86165  
    5959        self._file_path = file_path
    6060        self._handle_style_error = handle_style_error
     61        self._handle_style_error.turn_off_line_filtering()
    6162        self._tab_checker = TabChecker(file_path, handle_style_error)
    6263        self._output_regex = re.compile('Line:(?P<line>\d+)\s*(?P<message>.+)')
  • trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations_unittest.py

    r79176 r86165  
    5151    def __init__(self):
    5252        self._errors = []
     53        self.turned_off_filtering = False
     54
     55    def turn_off_line_filtering(self):
     56        self.turned_off_filtering = True
    5357
    5458    def __call__(self, lineno, category, confidence, message):
     
    6064    def reset_errors(self):
    6165        self._errors = []
     66        self.turned_off_filtering = False
    6267
    6368
     
    8287        checker.check_tabs(lines)
    8388        self.assertEqual(expected, self._error_collector.get_errors())
     89        self.assertTrue(self._error_collector.turned_off_filtering)
    8490
    8591    def test_valid_expectations(self):
  • trunk/Tools/Scripts/webkitpy/style/checkers/xml.py

    r74227 r86165  
    3232
    3333    def __init__(self, file_path, handle_style_error):
    34         self.file_path = file_path
    35         self.handle_style_error = handle_style_error
     34        self._handle_style_error = handle_style_error
     35        self._handle_style_error.turn_off_line_filtering()
    3636
    3737    def check(self, lines):
     
    4343            parser.Parse('', True)
    4444        except expat.ExpatError, error:
    45             self.handle_style_error(error.lineno, 'xml/syntax', 5, expat.ErrorString(error.code))
     45            self._handle_style_error(error.lineno, 'xml/syntax', 5, expat.ErrorString(error.code))
  • trunk/Tools/Scripts/webkitpy/style/checkers/xml_unittest.py

    r74149 r86165  
    3030
    3131
     32class MockErrorHandler(object):
     33    def __init__(self, handle_style_error):
     34        self.turned_off_filtering = False
     35        self._handle_style_error = handle_style_error
     36
     37    def turn_off_line_filtering(self):
     38        self.turned_off_filtering = True
     39
     40    def __call__(self, line_number, category, confidence, message):
     41        self._handle_style_error(self, line_number, category, confidence, message)
     42
     43
    3244class XMLCheckerTest(unittest.TestCase):
    3345    """Tests XMLChecker class."""
    3446
    3547    def assert_no_error(self, xml_data):
    36         def handle_style_error(line_number, category, confidence, message):
     48        def handle_style_error(mock_error_handler, line_number, category, confidence, message):
    3749            self.fail('Unexpected error: %d %s %d %s' % (line_number, category, confidence, message))
    38         checker = xml.XMLChecker('foo.xml', handle_style_error)
     50
     51        error_handler = MockErrorHandler(handle_style_error)
     52        checker = xml.XMLChecker('foo.xml', error_handler)
    3953        checker.check(xml_data.split('\n'))
     54        self.assertTrue(error_handler.turned_off_filtering)
    4055
    4156    def assert_error(self, expected_line_number, expected_category, xml_data):
    42         def handle_style_error(line_number, category, confidence, message):
    43             self.had_error = True
     57        def handle_style_error(mock_error_handler, line_number, category, confidence, message):
     58            mock_error_handler.had_error = True
    4459            self.assertEquals(expected_line_number, line_number)
    4560            self.assertEquals(expected_category, category)
    46         checker = xml.XMLChecker('foo.xml', handle_style_error)
     61
     62        error_handler = MockErrorHandler(handle_style_error)
     63        error_handler.had_error = False
     64
     65        checker = xml.XMLChecker('foo.xml', error_handler)
    4766        checker.check(xml_data.split('\n'))
    48         self.assertTrue(self.had_error)
     67        self.assertTrue(error_handler.had_error)
     68        self.assertTrue(error_handler.turned_off_filtering)
    4969
    5070    def mock_handle_style_error(self):
     
    5878
    5979    def test_init(self):
    60         checker = xml.XMLChecker('foo.xml', self.mock_handle_style_error)
    61         self.assertEquals(checker.file_path, 'foo.xml')
    62         self.assertEquals(checker.handle_style_error, self.mock_handle_style_error)
     80        error_handler = MockErrorHandler(self.mock_handle_style_error)
     81        checker = xml.XMLChecker('foo.xml', error_handler)
     82        self.assertEquals(checker._handle_style_error, error_handler)
    6383
    6484    def test_missing_closing_tag(self):
     
    6686
    6787    def test_no_error(self):
    68         checker = xml.XMLChecker('foo.xml', self.assert_no_error)
    69         checker.check(['<foo>', '</foo>'])
     88        self.assert_no_error('<foo>\n</foo>')
    7089
    7190if __name__ == '__main__':
  • trunk/Tools/Scripts/webkitpy/style/error_handlers.py

    r82382 r86165  
    129129        return self._line_numbers is None or line_number in self._line_numbers
    130130
     131    def turn_off_line_filtering(self):
     132        self._line_numbers = None
     133
    131134    def __call__(self, line_number, category, confidence, message):
    132135        """Handle the occurrence of a style error.
  • trunk/Tools/Scripts/webkitpy/style/error_handlers_unittest.py

    r58742 r86165  
    186186        self.assertEquals(self._error_messages,
    187187                          ["foo.h(50):  message  [whitespace/tab] [5]\n"])
     188
     189        # Error on non-modified line after turning off line filtering: error.
     190        error_handler.turn_off_line_filtering()
     191        self._call_error_handler(error_handler, confidence, line_number=60)
     192        self.assertEquals(2, self._error_count)
     193        self.assertEquals(self._error_messages,
     194                          ['foo.h(50):  message  [whitespace/tab] [5]\n',
     195                           'foo.h(60):  message  [whitespace/tab] [5]\n',
     196                           'Suppressing further [whitespace/tab] reports for this file.\n'])
Note: See TracChangeset for help on using the changeset viewer.