How to use the covimerage.DEFAULT_COVERAGE_DATA_FILE function in covimerage

To help you get started, we’ve selected a few covimerage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Vimjas / covimerage / tests / test_cli.py View on Github external
profiled_file_content = open(profiled_file, 'r').read()
    with tmpdir.as_cwd() as old_dir:
        profile_file = str(old_dir.join(
            'tests/fixtures/conditional_function.profile'))
        tmpdir.join(profiled_file).write(profiled_file_content, ensure=True)
        tmpdir.join('not-profiled.vim').write('')
        tmpdir.join('not-a-vim-file').write('')
        result = runner.invoke(cli.run, [
            '--no-wrap-profile', '--no-report',
            '--profile-file', profile_file,
            '--write-data',
            'printf', '--', '--headless'])

        # Read coverage.
        from covimerage.coveragepy import CoverageWrapper
        cov = CoverageWrapper(data_file=DEFAULT_COVERAGE_DATA_FILE)

    assert m.call_args[0] == (['printf', '--', '--headless'],)
    assert result.output.splitlines() == [
        'Running cmd: printf -- --headless (in %s)' % str(tmpdir),
        'Parsing profile file %s.' % profile_file,
        'Writing coverage file %s.' % DEFAULT_COVERAGE_DATA_FILE]
    assert result.exit_code == 0

    expected_cov_lines = {
        str(tmpdir.join('not-profiled.vim')): [],
        str(tmpdir.join('tests/test_plugin/conditional_function.vim')): [
            3, 8, 9, 11, 13, 14, 15, 17, 23]}
    assert cov.lines == expected_cov_lines
github Vimjas / covimerage / tests / test_cli.py View on Github external
def test_cli_write_coverage(runner, tmpdir):
    with tmpdir.as_cwd() as old_dir:
        with pytest.raises(SystemExit) as excinfo:
            cli.write_coverage([os.path.join(
                str(old_dir), 'tests/fixtures/conditional_function.profile')])
        assert excinfo.value.code == 0
        assert os.path.exists(DEFAULT_COVERAGE_DATA_FILE)

    result = runner.invoke(cli.main, ['write_coverage', '/does/not/exist'])
    if click.__version__ < '7.0':
        assert result.output.splitlines()[-1].startswith(
            'Error: Invalid value for "profile_file": Could not open file:')
    else:
        assert result.output.splitlines()[-1].startswith(
            'Error: Invalid value for "PROFILE_FILE...": Could not open file:')
    assert result.exit_code == 2

    result = runner.invoke(cli.main, ['write_coverage'])
    if click.__version__ < '7.0':
        expected = 'Error: Missing argument "profile_file".'
    else:
        expected = 'Error: Missing argument "PROFILE_FILE...".'
    assert result.output.splitlines()[-1] == expected
github Vimjas / covimerage / covimerage / cli.py View on Github external
              default=DEFAULT_COVERAGE_DATA_FILE,
              help=('DATA_FILE to write into.  '
                    u'[default:\xa0%s]' % DEFAULT_COVERAGE_DATA_FILE))
@click.option('--source', type=click.types.Path(exists=True), help=(
    'Source files/dirs to include.  This is necessary to include completely '
    'uncovered files.'), show_default=True, multiple=True)
@click.option('--append', is_flag=True, default=False, show_default=True,
              help='Read existing DATA_FILE for appending.')
def write_coverage(profile_file, data_file, source, append):
    """
    Parse PROFILE_FILE (output from Vim's :profile) and write it into DATA_FILE
    (Coverage.py compatible).
    """
    if append:
        m = MergedProfiles(source=source, append_to=data_file)
    else:
        m = MergedProfiles(source=source)
github Vimjas / covimerage / covimerage / cli.py View on Github external
              default=DEFAULT_COVERAGE_DATA_FILE, show_default=True)
@click.option('--include', required=False, multiple=True, help=(
    'Include only files whose paths match one of these patterns. '
    'Accepts shell-style wildcards, which must be quoted.'))
@click.option('--omit', required=False, multiple=True, help=(
    'Omit files whose paths match one of these patterns. '
    'Accepts shell-style wildcards, which must be quoted.'))
@click.option('--ignore-errors', is_flag=True, default=False,
              show_default=True, required=False,
              help='Ignore errors while reading source files.')
@click.pass_context
def xml(ctx, data_file, include, omit, ignore_errors):
    """
    A wrapper around `coverage xml`.

    This will automatically add covimerage as a plugin, and then just forwards
    most options.