Esempio n. 1
0
 def dispatch_processor(self, file_path):
     """Call dispatch_processor() with the given file path."""
     dispatcher = ProcessorDispatcher()
     processor = dispatcher.dispatch_processor(file_path,
                                               self.mock_handle_style_error,
                                               verbosity=3)
     return processor
Esempio n. 2
0
 def dispatch_processor(self, file_path):
     """Call dispatch_processor() with the given file path."""
     dispatcher = ProcessorDispatcher()
     processor = dispatcher.dispatch_processor(file_path,
                                               self.mock_handle_style_error,
                                               min_confidence=3)
     return processor
Esempio n. 3
0
    def test_check_file_on_skip_without_warning(self):
        """Test check_file() for a skipped-without-warning file."""

        file_path = "LayoutTests/foo.txt"

        dispatcher = ProcessorDispatcher()
        # Confirm that the input file is truly a skipped-without-warning file.
        self.assertTrue(dispatcher.should_skip_without_warning(file_path))

        # Check the outcome.
        self.call_check_file(file_path)
        self.assert_attributes(None, None, None, "")
Esempio n. 4
0
    def test_check_file_on_skip_without_warning(self):
        """Test check_file() for a skipped-without-warning file."""

        file_path = "LayoutTests/does_exist/foo.txt"

        dispatcher = ProcessorDispatcher()
        # Confirm that the input file is truly a skipped-without-warning file.
        self.assertTrue(dispatcher.should_skip_without_warning(file_path))

        # Check the outcome.
        self.call_check_file(file_path)
        self.assert_attributes(None, None, None, "")
    def test_check_file_on_skip_with_warning(self):
        """Test check_file() for a skipped-with-warning file."""

        file_path = "gtk2drawing.c"

        dispatcher = ProcessorDispatcher()
        # Check that the input file is truly a skipped-with-warning file.
        self.assertTrue(dispatcher.should_skip_with_warning(file_path))

        # Check the outcome.
        self.call_check_file(file_path)
        self.assert_attributes(None, None, None,
                               'Ignoring "gtk2drawing.c": this file is exempt from the style guide.\n')
Esempio n. 6
0
    def test_check_file_on_skip_with_warning(self):
        """Test check_file() for a skipped-with-warning file."""

        file_path = "does_exist/gtk2drawing.c"

        dispatcher = ProcessorDispatcher()
        # Check that the input file is truly a skipped-with-warning file.
        self.assertTrue(dispatcher.should_skip_with_warning(file_path))

        # Check the outcome.
        self.call_check_file(file_path)
        self.assert_attributes(None, None, None, "")
        self.assertLog(["WARNING: File exempt from style guide. "
                        'Skipping: "does_exist/gtk2drawing.c"\n'])
Esempio n. 7
0
    def test_check_file_on_skip_with_warning(self):
        """Test check_file() for a skipped-with-warning file."""

        file_path = "gtk2drawing.c"

        dispatcher = ProcessorDispatcher()
        # Check that the input file is truly a skipped-with-warning file.
        self.assertTrue(dispatcher.should_skip_with_warning(file_path))

        # Check the outcome.
        self.call_check_file(file_path)
        self.assert_attributes(
            None, None, None,
            'Ignoring "gtk2drawing.c": this file is exempt from the style guide.\n'
        )
    def test_should_skip_without_warning(self):
        """Test should_skip_without_warning()."""
        dispatcher = ProcessorDispatcher()

        # Check a non-skipped file.
        self.assertFalse(dispatcher.should_skip_without_warning("foo.txt"))

        # Check skipped files.
        paths_to_skip = [
            # LayoutTests folder
            "LayoutTests/foo.txt"
        ]

        for path in paths_to_skip:
            self.assertTrue(dispatcher.should_skip_without_warning(path), "Checking: " + path)
Esempio n. 9
0
    def test_should_skip_without_warning(self):
        """Test should_skip_without_warning()."""
        dispatcher = ProcessorDispatcher()

        # Check a non-skipped file.
        self.assertFalse(dispatcher.should_skip_without_warning("foo.txt"))

        # Check skipped files.
        paths_to_skip = [
            # LayoutTests folder
            "LayoutTests/foo.txt",
        ]

        for path in paths_to_skip:
            self.assertTrue(dispatcher.should_skip_without_warning(path),
                            "Checking: " + path)
    def test_check_file_on_non_skipped(self):

        # We use a C++ file since by using a CppProcessor, we can check
        # that all of the possible information is getting passed to
        # process_file (in particular, the verbosity).
        file_base = "foo"
        file_extension = "cpp"
        file_path = file_base + "." + file_extension

        dispatcher = ProcessorDispatcher()
        # Check that the input file is truly a C++ file.
        self.assertEquals(dispatcher._file_type(file_path), style.FileType.CPP)

        # Check the outcome.
        self.call_check_file(file_path)

        expected_processor = CppProcessor(file_path, file_extension, self.mock_handle_style_error, 3)

        self.assert_attributes(file_path, self.mock_handle_style_error, expected_processor, "")
Esempio n. 11
0
    def test_check_file_on_non_skipped(self):

        # We use a C++ file since by using a CppProcessor, we can check
        # that all of the possible information is getting passed to
        # process_file (in particular, the verbosity).
        file_base = "foo"
        file_extension = "cpp"
        file_path = file_base + "." + file_extension

        dispatcher = ProcessorDispatcher()
        # Check that the input file is truly a C++ file.
        self.assertEquals(dispatcher._file_type(file_path), style.FileType.CPP)

        # Check the outcome.
        self.call_check_file(file_path)

        expected_processor = CppProcessor(file_path, file_extension,
                                          self.mock_handle_style_error, 3)

        self.assert_attributes(file_path, self.mock_handle_style_error,
                               expected_processor, "")
    def test_should_skip_with_warning(self):
        """Test should_skip_with_warning()."""
        dispatcher = ProcessorDispatcher()

        # Check a non-skipped file.
        self.assertFalse(dispatcher.should_skip_with_warning("foo.txt"))

        # Check skipped files.
        paths_to_skip = [
            "gtk2drawing.c",
            "gtk2drawing.h",
            "JavaScriptCore/qt/api/qscriptengine_p.h",
            "WebCore/platform/gtk/gtk2drawing.c",
            "WebCore/platform/gtk/gtk2drawing.h",
            "WebKit/gtk/tests/testatk.c",
            "WebKit/qt/Api/qwebpage.h",
            "WebKit/qt/tests/qwebsecurityorigin/tst_qwebsecurityorigin.cpp",
        ]

        for path in paths_to_skip:
            self.assertTrue(dispatcher.should_skip_with_warning(path), "Checking: " + path)
Esempio n. 13
0
    def test_should_skip_with_warning(self):
        """Test should_skip_with_warning()."""
        dispatcher = ProcessorDispatcher()

        # Check a non-skipped file.
        self.assertFalse(dispatcher.should_skip_with_warning("foo.txt"))

        # Check skipped files.
        paths_to_skip = [
            "gtk2drawing.c",
            "gtk2drawing.h",
            "JavaScriptCore/qt/api/qscriptengine_p.h",
            "WebCore/platform/gtk/gtk2drawing.c",
            "WebCore/platform/gtk/gtk2drawing.h",
            "WebKit/gtk/tests/testatk.c",
            "WebKit/qt/Api/qwebpage.h",
            "WebKit/qt/tests/qwebsecurityorigin/tst_qwebsecurityorigin.cpp",
        ]

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