Пример #1
0
 def run(self, argv):
     output = _FilteredStringIO(self.FALSE_POSITIVES)
     with OutputCaptureScope():
         from webkitpy.thirdparty.autoinstalled.pylint import lint
         from webkitpy.thirdparty.autoinstalled.pylint.reporters.text import ParseableTextReporter
         lint.Run(['--rcfile', self._pylintrc] + argv, reporter=ParseableTextReporter(output=output), exit=False)
     return output
Пример #2
0
    def test_no_linter_errors(self):
        host = self._generate_testing_host()

        scope = OutputCaptureScope(OutputCapture(logging.ERROR))
        with scope:
            file_reader = self._generate_file_reader(host.filesystem)
            file_reader.do_association_check('/mock-checkout', host)
        self.assertEqual(scope.captured_output, ('', '', ''))
Пример #3
0
    def test_output_capture_scope(self):
        scope = OutputCaptureScope()
        with scope:
            print('STRING 1')
        self.assertEqual(('STRING 1\n', '', ''), scope.captured_output)

        with scope:
            print('STRING 2')
        self.assertEqual(('STRING 2\n', '', ''), scope.captured_output)
Пример #4
0
    def test_linter_deleted_file_no_edit(self):
        files = {
            '/mock-checkout/LayoutTests/TestExpectations':
            '# TestExpectations\ncss1/deleted-test.html [ Failure ]\n'}
        host = self._generate_testing_host(files)

        scope = OutputCaptureScope(OutputCapture(logging.ERROR))
        with scope:
            file_reader = self._generate_file_reader(host.filesystem)
            file_reader.delete_file('/mock-checkout/LayoutTests/css1/other-deleted-test.html')
            file_reader.do_association_check('/mock-checkout', host)
        self.assertEqual(scope.captured_output, ('', '', ''))
Пример #5
0
    def test_linter_added_file_with_error(self):
        files = {
            '/mock-checkout/LayoutTests/TestExpectations':
            '# TestExpectations\ncss1/test.html [ Failure ]\ncss1/test.html [ Failure ]\n'}
        host = self._generate_testing_host(files)

        scope = OutputCaptureScope(OutputCapture(logging.ERROR))
        with scope:
            file_reader = self._generate_file_reader(host.filesystem)
            file_reader.process_file('/mock-checkout/LayoutTests/TestExpectations', line_numbers=[1, 2, 3])
            file_reader.do_association_check('/mock-checkout', host)
        self.assertEqual(scope.captured_output, ('', '', '/mock-checkout/LayoutTests/TestExpectations:3:  Duplicate or ambiguous entry lines LayoutTests/TestExpectations:2 and LayoutTests/TestExpectations:3.  [test/expectations] [5]\n'))
Пример #6
0
    def test_linter_duplicate_line_edit_in_file(self):
        files = {
            '/mock-checkout/LayoutTests/TestExpectations':
            '# TestExpectations\ncss1/test.html [ Failure ]\ncss1/test.html [ Failure ]\n'}
        host = self._generate_testing_host(files)

        scope = OutputCaptureScope(OutputCapture(logging.ERROR))
        with scope:
            file_reader = self._generate_file_reader(host.filesystem)
            file_reader.process_file('/mock-checkout/LayoutTests/TestExpectations', line_numbers=[1])
            file_reader.do_association_check('/mock-checkout', host)
        self.assertEqual(scope.captured_output, ('', '', ''))
Пример #7
0
    def test_linter_duplicate_line_no_edit(self):
        files = {
            '/mock-checkout/LayoutTests/TestExpectations':
            '# TestExpectations\ncss1/test.html [ Failure ]\ncss1/test.html [ Failure ]\n'}
        host = self._generate_testing_host(files)

        scope = OutputCaptureScope()
        with scope:
            file_reader = self._generate_file_reader(host.filesystem)
            file_reader.process_paths(['/mock-checkout/LayoutTests/platform/ios/TestExpectations'])
            file_reader.do_association_check('/mock-checkout', host)
        self.assertEqual(scope.captured_output, ('', '', ''))
Пример #8
0
    def test_linter_deleted_file(self):
        files = {
            '/mock-checkout/LayoutTests/TestExpectations':
            '# TestExpectations\ncss1/deleted-test.html [ Failure ]\n'}
        host = self._generate_testing_host(files)
        host = self._generate_testing_host(files)

        scope = OutputCaptureScope()
        with scope:
            file_reader = self._generate_file_reader(host.filesystem)
            file_reader.delete_file('/mock-checkout/LayoutTests/css1/deleted-test.html')
            file_reader.do_association_check('/mock-checkout', host)
        self.assertEqual(
            scope.captured_output,
            ('', '', '/mock-checkout/LayoutTests/TestExpectations:2:  Path does not exist.  [test/expectations] [5]\n'))
Пример #9
0
 def test_output_capture_scope_from_output_capture(self):
     scope = OutputCaptureScope(self.output)
     with scope:
         self.log_all_levels()
     self.assertEqual(('', '', 'INFO\nWARN\nERROR\nCRITICAL\n'),
                      scope.captured_output)