def run():
    """Run cpp coverage."""
    import json
    import os
    import sys
    from . import coverage, report

    args = coverage.create_args(sys.argv[1:])

    if args.verbose:
        print('encodings: {}'.format(args.encodings))

    yml = parse_yaml_config(args)

    if not args.repo_token:
        # try get token from yaml first
        args.repo_token = yml.get('repo_token', '')
    if not args.repo_token:
        # use environment COVERALLS_REPO_TOKEN as a fallback
        args.repo_token = os.environ.get('COVERALLS_REPO_TOKEN')

    args.service_name = yml.get('service_name', 'travis-ci')

    if not args.gcov_options:
        args.gcov_options = yml.get('gcov_options', '')
    if not args.root:
        args.root = yml.get('root', '.')
    if not args.build_root:
        args.build_root = yml.get('build_root', '')

    args.exclude.extend(yml.get('exclude', []))
    args.include.extend(yml.get('include', []))
    args.exclude_lines_pattern.extend(yml.get('exclude_lines_pattern', []))

    args.service_job_id = os.environ.get('TRAVIS_JOB_ID', '')

    if args.repo_token == '' and args.service_job_id == '':
        raise ValueError("\nno coveralls.io token specified and no travis job id found\n"
                         "see --help for examples on how to specify a token\n")

    if not args.no_gcov:
        coverage.run_gcov(args)
    cov_report = coverage.collect(args)
    if args.verbose:
        print(cov_report)
    if args.dryrun:
        return 0
    if args.dump:
        args.dump.write(json.dumps(cov_report))
        return 0

    return report.post_report(cov_report, args)
def run ( ) : import json import os import sys from . import coverage , report args = coverage . create_args ( sys . argv [ 1 : ] ) if args . verbose : print ( 'encodings: {}' . format ( args . encodings ) ) yml = parse_yaml_config ( args ) if not args . repo_token : args . repo_token = yml . get ( 'repo_token' , '' ) if not args . repo_token : args . repo_token = os . environ . get ( 'COVERALLS_REPO_TOKEN' ) args . service_name = yml . get ( 'service_name' , 'travis-ci' ) if not args . gcov_options : args . gcov_options = yml . get ( 'gcov_options' , '' ) if not args . root : args . root = yml . get ( 'root' , '.' ) if not args . build_root : args . build_root = yml . get ( 'build_root' , '' ) args . exclude . extend ( yml . get ( 'exclude' , [ ] ) ) args . include . extend ( yml . get ( 'include' , [ ] ) ) args . exclude_lines_pattern . extend ( yml . get ( 'exclude_lines_pattern' , [ ] ) ) args . service_job_id = os . environ . get ( 'TRAVIS_JOB_ID' , '' ) if args . repo_token == '' and args . service_job_id == '' : raise ValueError ( "\nno coveralls.io token specified and no travis job id found\n" "see --help for examples on how to specify a token\n" ) if not args . no_gcov : coverage . run_gcov ( args ) cov_report = coverage . collect ( args ) if args . verbose : print ( cov_report ) if args . dryrun : return 0 if args . dump : args . dump . write ( json . dumps ( cov_report ) ) return 0 return report . post_report ( cov_report , args )
Run cpp coverage.