Skip to main content

Generate coverage information for Vim scripts.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

covimerage-0.2.1.tar.gz (35.9 kB view details)

Uploaded Source

Built Distribution

covimerage-0.2.1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file covimerage-0.2.1.tar.gz.

File metadata

  • Download URL: covimerage-0.2.1.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.4

File hashes

Hashes for covimerage-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a75fd6a4f7d743e40977f2f1d556040e8fad5a1122dbf8d63cd759d811fd64f6
MD5 b0ee9dd8ca8a6ef7c68e21a92f43aa25
BLAKE2b-256 a1be0bcf26319fd2a1da72385af9cc02008fa304c6528205a5b2b41abd9a3693

See more details on using hashes here.

File details

Details for the file covimerage-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: covimerage-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.4

File hashes

Hashes for covimerage-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54b90070b993421c07586e281d11c27fa37461f922aed6b364b8d720bd403dac
MD5 9373390d5488e46247f02cd86ff12ea3
BLAKE2b-256 92c8b5b28a181ca5279c39ec5d8329f9034166619b92f15cfa54e9c99ae3d291

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page