Skip to main content

covimerage

Generates code coverage information for Vim scripts.

It parses the output from Vim's :profile command, and generates data compatible with Coverage.py.

Build Status codecov Codacy Badge

Installation

You can install covimerage using pip:

pip install covimerage

Simple usage

You can use covimerage run to wrap the call to Neovim/Vim with necessary boilerplate:

covimerage run vim -Nu test/vimrc -c 'Vader! test/**'

This will write the file .coverage_covimerage by default (use --data-file to configure it), which is compatible with Coverage.py. A report is automatically generated (on stdout).

You can then call covimerage xml to create a coverage.xml file (Cobertura-compatible), which tools like Codecov's codecov tool can consume, e.g. via codecov -f coverage.xml.

Manual/advanced usage

1. Generate profile information for your Vim script(s)

You have to basically add the following to your tests vimrc:

profile start /tmp/vim-profile.txt
profile! file ./*

This makes Neovim/Vim then write a file with profiling information.

2. Call covimerage on the output file(s)

covimerage write_coverage /tmp/vim-profile.txt

This will create a file .coverage_covimerage (the default for --data-file), with entries marked for processing by a Coverage.py plugin (provided by covimerage)).

3. Include the covimerage plugin in .coveragerc

When using coverage on the generated output (data file), you need to add the covimerage plugin to the .coveragerc file (which Coverage.py uses). This is basically all the .coveragerc you will need, but you could use other settings here (for Coverage.py), e.g. to omit some files:

[run]
plugins = covimerage
data_file = .coverage_covimerage

4. Create the report(s)

You can now call e.g. coverage report -m, and you should be able to use coverage reporting platforms like https://codecov.io/ or https://coveralls.io, which are basically using coverage xml.

Reference implementation

Caveats

Coverage information for a function may get wiped if the function is re-defined after testing it. This is a known limitation that does not depend on the implementation of covimerage, but on the vim profiler itself, since profiling data for a function, used to extract coverage data, is reset when the function is re-defined, even if the definition is identical.

This can be an issue if the source files being checked for coverage are reloaded with runtime between tests for some reasons, e.g. when mocking some function. To prevent coverage information from being lost, one solution is to write such tests in a different suite that is run separately, and combine the coverage results with covimerage run --append.

Links

TODO

Metadata

Release files for covimerage 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for covimerage 0.2.2
File Size Uploaded
covimerage-0.2.2.tar.gz 37.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for covimerage 0.2.2
File Interpreter ABI Platform
covimerage-0.2.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 54.4 kB

Release files / covimerage-0.2.2.tar.gz

Download URL covimerage-0.2.2.tar.gz
Size 37.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5ef40302f028c86fa7c6b30f5a0026b5049df7635680d49190ae5575b81ca3ba
BLAKE2b-256 checksum
How to use checksums
e7fd45a6ce480ac42e53b5d6cf6c8c93620e5d2ba39060df2713fff00651e2de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / covimerage-0.2.2-py2.py3-none-any.whl

Download URL covimerage-0.2.2-py2.py3-none-any.whl
Size 17.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
58f2759e78112156185939bdc1c36b0c5f2cd7cfa101641c0daa90ee64c687b9
BLAKE2b-256 checksum
How to use checksums
a31904e4dc9bc8d60f8fc283ca8ad912c22857f88988362ffc7f434520c95340
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page