LocalCoverage.jl

Trivial functions for working with coverage for packages locally.
Author JuliaCI
Popularity
35 Stars
Updated Last
2 Years Ago
Started In
March 2018

LocalCoverage.jl

lifecycle build codecov.io

This is a collection of trivial functions to facilitate generating and exploring test coverage information for Julia packages locally, without using any remote/cloud services.

Installation

Pkg.add("LocalCoverage")

or ]add LocalCoverage from the Julia REPL.

Optional Dependencies

The package has several optional features which require additional dependencies. lcov is required for generating HTML output. You can install it via

  • Debian/Ubuntu: sudo apt install lcov
  • Arch/Manjaro: yay -S lcov

Note that the code in this package assumes a reasonably recent lcov version when calling genhtml, ideally 1.13, but 1.12 should work too. This does not prevent installation, only emits a warning.

LocalCoverage also provides an option to generate a Cobertura XML, which is used by JVM-related test suites such as Jenkins. Using this requires the Python module lcov_cobertura. With Python installed, you can install this module via pip install lcov_cobertura.

Usage

When generating test coverage, Julia places annotated *.cov source code files in the same directory as the source code itself. In addition, summary files will be placed in the coverage subdirectory of the package directory. We recommend using this package with packages added with the Pkg.dev installation option (which allows for easy manipulation of the package directory).

To generate test coverage files do

using LocalCoverage
# pkg is the package name as a string, e.g. "LocalCoverage"
generate_coverage(pkg, genhtml=true, show_summary=true, genxml=false) # defaults shown

You can then navigate to the coverage subdirectory of the package directory (e.g. ~/.julia/dev/PackageName/coverage) and see the generated coverage summaries.

To open the coverage report HTML in a browser do

open_coverage(pkg)

To delete all coverage files do

clean_coverage(pkg, rm_directory=true) # defaults shown

Used By Packages

No packages found.