Beispiel #1
0
 def dispatch(self, file_path):
     """Call dispatch() with the given file path."""
     dispatcher = CheckerDispatcher()
     self.mock_handle_style_error = DefaultStyleErrorHandler('', None, None, [])
     checker = dispatcher.dispatch(file_path,
                                   self.mock_handle_style_error,
                                   min_confidence=3)
     return checker
Beispiel #2
0
 def dispatch(self, file_path):
     """Call dispatch() with the given file path."""
     dispatcher = CheckerDispatcher()
     self.mock_handle_style_error = DefaultStyleErrorHandler('', None, None, [])
     checker = dispatcher.dispatch(file_path,
                                   self.mock_handle_style_error,
                                   min_confidence=3)
     return checker
Beispiel #3
0
    def test_should_check_and_strip_carriage_returns(self):
        files = {
            'foo.txt': True,
            'foo.cpp': True,
            'foo.vcproj': False,
            'foo.vsprops': False,
        }

        dispatcher = CheckerDispatcher()
        for file_path, expected_result in files.items():
            self.assertEqual(dispatcher.should_check_and_strip_carriage_returns(file_path), expected_result, 'Checking: %s' % file_path)
Beispiel #4
0
    def test_should_check_and_strip_carriage_returns(self):
        files = {
            'foo.txt': True,
            'foo.cpp': True,
            'foo.vcproj': False,
            'foo.vsprops': False,
        }

        dispatcher = CheckerDispatcher()
        for file_path, expected_result in files.items():
            self.assertEqual(dispatcher.should_check_and_strip_carriage_returns(
                file_path), expected_result, 'Checking: %s' % file_path)
 def setUp(self):
     self._dispatcher = CheckerDispatcher()
class CheckerDispatcherSkipTest(unittest.TestCase):
    """Tests the "should skip" methods of the CheckerDispatcher class."""
    def setUp(self):
        self._dispatcher = CheckerDispatcher()

    def test_should_skip_with_warning(self):
        """Test should_skip_with_warning()."""
        # Check skipped files.
        paths_to_skip = [
            "Source/WebKit/gtk/tests/testatk.c",
            "Source/WebKit2/UIProcess/API/gtk/webkit2.h",
            "Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h",
            "Source/WebKit2/UIProcess/API/gtk/WebKitLoader.h",
        ]

        for path in paths_to_skip:
            self.assertTrue(self._dispatcher.should_skip_with_warning(path),
                            "Checking: " + path)

        # Verify that some files are not skipped.
        paths_not_to_skip = [
            "foo.txt",
            "Source/WebKit2/UIProcess/API/gtk/HelperClass.cpp",
            "Source/WebKit2/UIProcess/API/gtk/HelperClass.h",
            "Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp",
            "Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h",
            "Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp",
            "Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h",
        ]

        for path in paths_not_to_skip:
            self.assertFalse(self._dispatcher.should_skip_with_warning(path))

    def _assert_should_skip_without_warning(self, path, is_checker_none,
                                            expected):
        # Check the file type before asserting the return value.
        checker = self._dispatcher.dispatch(file_path=path,
                                            handle_style_error=None,
                                            min_confidence=3)
        message = 'while checking: %s' % path
        self.assertEqual(checker is None, is_checker_none, message)
        self.assertEqual(self._dispatcher.should_skip_without_warning(path),
                         expected, message)

    def test_should_skip_without_warning__true(self):
        """Test should_skip_without_warning() for True return values."""
        # Check a file with NONE file type.
        path = 'foo.asdf'  # Non-sensical file extension.
        self._assert_should_skip_without_warning(path,
                                                 is_checker_none=True,
                                                 expected=True)

        # Check files with non-NONE file type.  These examples must be
        # drawn from the _SKIPPED_FILES_WITHOUT_WARNING configuration
        # variable.
        path = os.path.join('LayoutTests', 'foo.txt')
        self._assert_should_skip_without_warning(path,
                                                 is_checker_none=False,
                                                 expected=True)

    def test_should_skip_without_warning__false(self):
        """Test should_skip_without_warning() for False return values."""
        paths = [
            'foo.txt',
            os.path.join('LayoutTests', 'TestExpectations'),
        ]

        for path in paths:
            self._assert_should_skip_without_warning(path,
                                                     is_checker_none=False,
                                                     expected=False)
Beispiel #7
0
 def setUp(self):
     self._dispatcher = CheckerDispatcher()
Beispiel #8
0
class CheckerDispatcherSkipTest(unittest.TestCase):

    """Tests the "should skip" methods of the CheckerDispatcher class."""

    def setUp(self):
        self._dispatcher = CheckerDispatcher()

    def test_should_skip_with_warning(self):
        """Test should_skip_with_warning()."""
        # Check skipped files.
        paths_to_skip = [
            "Source/WebKit/gtk/tests/testatk.c",
            "Source/WebKit2/UIProcess/API/gtk/webkit2.h",
            "Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h",
            "Source/WebKit2/UIProcess/API/gtk/WebKitLoader.h",
        ]

        for path in paths_to_skip:
            self.assertTrue(self._dispatcher.should_skip_with_warning(path),
                            "Checking: " + path)

        # Verify that some files are not skipped.
        paths_not_to_skip = [
            "foo.txt",
            "Source/WebKit2/UIProcess/API/gtk/HelperClass.cpp",
            "Source/WebKit2/UIProcess/API/gtk/HelperClass.h",
            "Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp",
            "Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h",
            "Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp",
            "Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h",
        ]

        for path in paths_not_to_skip:
            self.assertFalse(self._dispatcher.should_skip_with_warning(path))

    def _assert_should_skip_without_warning(self, path, is_checker_none,
                                            expected):
        # Check the file type before asserting the return value.
        checker = self._dispatcher.dispatch(file_path=path,
                                            handle_style_error=None,
                                            min_confidence=3)
        message = 'while checking: %s' % path
        self.assertEqual(checker is None, is_checker_none, message)
        self.assertEqual(self._dispatcher.should_skip_without_warning(path),
                         expected, message)

    def test_should_skip_without_warning__true(self):
        """Test should_skip_without_warning() for True return values."""
        # Check a file with NONE file type.
        path = 'foo.asdf'  # Non-sensical file extension.
        self._assert_should_skip_without_warning(path,
                                                 is_checker_none=True,
                                                 expected=True)

        # Check files with non-NONE file type.  These examples must be
        # drawn from the _SKIPPED_FILES_WITHOUT_WARNING configuration
        # variable.
        path = os.path.join('LayoutTests', 'foo.txt')
        self._assert_should_skip_without_warning(path,
                                                 is_checker_none=False,
                                                 expected=True)

    def test_should_skip_without_warning__false(self):
        """Test should_skip_without_warning() for False return values."""
        paths = ['foo.txt',
                 os.path.join('LayoutTests', 'TestExpectations'),
                 ]

        for path in paths:
            self._assert_should_skip_without_warning(path,
                                                     is_checker_none=False,
                                                     expected=False)