コード例 #1
0
 def test_check_patch_with_png_deletion(self):
     PatchReader(self._file_reader).check(
         'diff --git a/foo-expected.png b/foo-expected.png\n'
         'deleted file mode 100644\n'
         'index ef65bee..0000000\n'
         'Binary files a/foo-expected.png and /dev/null differ\n')
     self._assert_checked(passed_to_process_file=[],
                          delete_only_file_count=1)
コード例 #2
0
 def test_check_patch(self):
     PatchReader(self._file_reader).check(
         'diff --git a/__init__.py b/__init__.py\n'
         'index ef65bee..e3db70e 100644\n'
         '--- a/__init__.py\n'
         '+++ b/__init__.py\n'
         '@@ -1,1 +1,2 @@\n'
         ' # Required for Python to search this directory for module files\n'
         '+# New line\n')
     self._assert_checked(passed_to_process_file=[('__init__.py', [2])],
                          delete_only_file_count=0)
コード例 #3
0
 def test_check_patch_with_deletion(self):
     PatchReader(self._file_reader).check(
         'diff --git a/__init__.py b/__init.py\n'
         'deleted file mode 100644\n'
         'index ef65bee..0000000\n'
         '--- a/__init__.py\n'
         '+++ /dev/null\n'
         '@@ -1 +0,0 @@\n'
         '-foobar\n')
     # The deleted file isn't be processed.
     self._assert_checked(passed_to_process_file=[],
                          delete_only_file_count=1)
コード例 #4
0
    def main(self):
        args = sys.argv[1:]

        host = Host()
        host.initialize_scm()

        stderr = self._engage_awesome_stderr_hacks()

        # Checking for the verbose flag before calling check_webkit_style_parser()
        # lets us enable verbose logging earlier.
        is_verbose = "-v" in args or "--verbose" in args

        checker.configure_logging(stream=stderr, is_verbose=is_verbose)
        _log.debug("Verbose logging enabled.")

        parser = checker.check_webkit_style_parser()
        (paths, options) = parser.parse(args)

        configuration = checker.check_webkit_style_configuration(options)

        paths = change_directory(host.filesystem,
                                 checkout_root=host.scm().checkout_root,
                                 paths=paths)

        style_processor = StyleProcessor(configuration)
        file_reader = TextFileReader(host.filesystem, style_processor)

        if paths and not options.diff_files:
            file_reader.process_paths(paths)
            file_reader.do_association_check(host.scm().checkout_root)
        else:
            changed_files = paths if options.diff_files else None
            patch = host.scm().create_patch(options.git_commit,
                                            changed_files=changed_files,
                                            git_index=options.git_index)
            patch_checker = PatchReader(file_reader)
            patch_checker.check(patch)

        error_count = style_processor.error_count
        file_count = file_reader.file_count
        delete_only_file_count = file_reader.delete_only_file_count

        _log.info("Total errors found: %d in %d files" %
                  (error_count, file_count))
        # We fail when style errors are found or there are no checked files.
        return error_count > 0 or (file_count == 0
                                   and delete_only_file_count == 0)
コード例 #5
0
 def setUp(self):
     file_reader = self.MockTextFileReader()
     self._file_reader = file_reader
     self._patch_checker = PatchReader(file_reader)