コード例 #1
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)
コード例 #2
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)
        else:
            changed_files = paths if options.diff_files else None
            patch = host.scm().create_patch(options.git_commit, changed_files=changed_files)
            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
コード例 #3
0
ファイル: main_unittest.py プロジェクト: eocanha/webkit
 def setUp(self):
     parser = checker.check_webkit_style_parser()
     (_, options) = parser.parse([])
     self._style_checker_configuration = checker.check_webkit_style_configuration(
         options)
コード例 #4
0
 def test_check_webkit_style_configuration(self):
     # Exercise the code path to make sure the function does not error out.
     option_values = CommandOptionValues()
     check_webkit_style_configuration(option_values)
コード例 #5
0
ファイル: test.py プロジェクト: Open-Transport/synthese
    def run_style_tests(self, suite_args):

        # TODO: not yet ready
        return True

        # Code based on http://svn.webkit.org/repository/webkit/trunk/Tools/Scripts/check-webkit-style

        thisdir = os.path.dirname(os.path.abspath(__file__))

        args = suite_args
        if not args:
            args = [os.path.abspath(
                os.path.join(thisdir, os.pardir, os.pardir, os.pardir)
            )]
        _log = log

        sys.path.append(os.path.join(thisdir, os.pardir, 'third_party'))

        from webkitpy.style_references import detect_checkout
        import webkitpy.style.checker as checker
        from webkitpy.style.patchreader import PatchReader
        from webkitpy.style.checker import StyleProcessor
        from webkitpy.style.filereader import TextFileReader
        from webkitpy.style.main import change_directory

        # Change stderr to write with replacement characters so we don't die
        # if we try to print something containing non-ASCII characters.
        stderr = codecs.StreamReaderWriter(sys.stderr,
                                           codecs.getreader('utf8'),
                                           codecs.getwriter('utf8'),
                                           'replace')
        # Setting an "encoding" attribute on the stream is necessary to
        # prevent the logging module from raising an error.  See
        # the checker.configure_logging() function for more information.
        stderr.encoding = "UTF-8"

        # FIXME: Change webkitpy.style so that we do not need to overwrite
        #        the global sys.stderr.  This involves updating the code to
        #        accept a stream parameter where necessary, and not calling
        #        sys.stderr explicitly anywhere.
        sys.stderr = stderr

        #SYNTH args = sys.argv[1:]

        # 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)

        checkout = detect_checkout()

        if checkout is None:
            if not paths:
                _log.error("WebKit checkout not found: You must run this script "
                           "from within a WebKit checkout if you are not passing "
                           "specific paths to check.")
                sys.exit(1)

            checkout_root = None
            _log.debug("WebKit checkout not found for current directory.")
        else:
            checkout_root = checkout.root_path()
            _log.debug("WebKit checkout found with root: %s" % checkout_root)

        configuration = checker.check_webkit_style_configuration(options)

        paths = change_directory(checkout_root=checkout_root, paths=paths)

        style_processor = StyleProcessor(configuration)

        file_reader = TextFileReader(style_processor)

        if paths and not options.diff_files:
            file_reader.process_paths(paths)
        else:
            changed_files = paths if options.diff_files else None
            patch = checkout.create_patch(options.git_commit, changed_files=changed_files)
            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.
        #sys.exit(error_count > 0 or (file_count == 0 and delete_only_file_count == 0))
        return not (error_count > 0 or (file_count == 0 and delete_only_file_count == 0))
コード例 #6
0
ファイル: checker_unittest.py プロジェクト: mirror/chromium
 def test_check_webkit_style_configuration(self):
     # Exercise the code path to make sure the function does not error out.
     option_values = CommandOptionValues()
     check_webkit_style_configuration(option_values)