Reference

Contents

Index

ExtendedLocalCoverage.default_html_functionMethod
default_html_function(lines_function)

Extract the default function to be passed as html_function argument to generate_html_report.

It takes the lines_function as an argument and returns highlight_with_show if the lines_function is ExtendedLocalCoverage.highlighted_lines and simply return the String constructor otherwise.

source
ExtendedLocalCoverage.default_lines_functionMethod
default_lines_function()

Extract the default function to be passed as lines_function argument to generate_html_report.

If the JuliaSyntaxHighlighting package is loaded, this returns the ExtendedLocalCoverage.highlighted_lines function, otherwise it returns the ExtendedLocalCoverage.plain_lines function.

source
ExtendedLocalCoverage.generate_html_reportMethod
generate_html_report(lcov_file, html_file; title = nothing, pkg_dir = nothing)

Generate a static HTML report from a LCOV file using a native Julia solution.

The lcov_file and html_file arguments are the full paths to the LCOV file used as input and of the HTML file to be generated, respectively.

Keyword arguments

  • title = "Package Coverage Report" is the title used at the top of the HTML report.
  • pkg_dir is the directory of the package being covered. It is used to generate the source code links in the HTML report.
  • lines_function is a function that takes an IO stream representing the contents of a file and returns a vector of AbstractString objects representing each line of the source file. When not provided, it defaults to ExtendedLocalCoverage.default_lines_function.
  • html_function is a function that takes a single line of source code as an AbstractString and returns an HTML-safe representation of that line, potentially with syntax highlighting. When not provided, it defaults to ExtendedLocalCoverage.default_html_function.
source
ExtendedLocalCoverage.generate_package_coverageFunction
generate_package_coverage(pkg = nothing; kwargs...)

Generate a summary of coverage results for package pkg.

If no pkg is supplied, the method operates in the currently active package. This acts similary to (and based on) the generate_coverage function from LocalCoverage.jl, but providing two main differences:

  • It automatically extracts the list of files included by the package using Revise.parse_pkg_files.
  • It allows to generate an HTML report (does so by default) using the pycobertura Python package which is installed by default via CondaPkg.
    • In contrast, the HTML report from LocalCoverage.jl relies on lcov being already available on your system and does not work on Windows machines.

Keyword arguments (and their defaults)

  • use_existing_lcov = false if true, the coverage is assumed to be already computed and available in coverage/lcov.info within the package directory. If false, the coverage is generated from scratch calling LocalCoverage.generate_coverage.

  • run_test = true this is forwarded to LocalCoverage.generate_coverage and determines whether tests are executed. When false, test execution step is skipped allowing an easier use in combination with other test packages.

  • test_args = [""] this is forwarded to LocalCoverage.generate_coverage and is there passed on to Pkg.test.

  • exclude = [] is used to specify string or regexes that are used to filter out some of the files in the list of package includes. The exclusion is done by removing from the list of files all files for which occursin(needle, filename) returns true, where needle is any element of exclude.

  • html_name = "index.html" is the name of the HTML file to be generated. If nothing is provided, no HTML report is generated. The report is always generated in the coverage subdirectory of the target package directory.

  • cobertura_name = "cobertura-coverage.xml" is the name of the cobertura XML file to be generated. If nothing is provided both to this kwarg and to html_name, no cobertura XML file is generated. The file is always generated in the coverage subdirectory of the target package directory.

  • print_to_stdout = true determines whether the coverage summary is printed to the standard output.

  • extensions = true when true, also tries to add to the coverage files in the ext directory that match an extension name specified in the Project.toml file.

  • lines_function use to customize how the HTML report is generated. Is directly forwarded to generate_html_report and can only be provided if the html_name kwarg is also provided.

  • html_function use to customize how the HTML report is generated. Is directly forwarded to generate_html_report and can only be provided if the html_name kwarg is also provided.

Return values

The function returns a named tuple with the following fields:

  • cov the coverage summary as returned by LocalCoverage.generate_coverage.
  • cobertura_file the full path to the cobertura XML file, if any was generated.
  • html_file the full path to the HTML file, if any was generated.
source
ExtendedLocalCoverage.highlight_with_showFunction
highlight_with_show(line::Union{AnnotatedString, SubString{<:AnnotatedString}}) -> String

Take as input an annotated string containing synthax highlighting and generate an HTML representation of it using the show method with MIME"text/html"(), relying on StyledStrings.jl implementation to create HTML with synthax highlighting.

source
ExtendedLocalCoverage.plain_linesMethod
plain_lines(io::IO)

Extract lines from the given IO stream and return them as plain text without any syntax highlighting.

This function simply does collect(eachline(io)) and is the default fallback used as lines_function when JuliaSyntaxHighlighting.jl is not loaded.

source