CoverageTools.LCOVModule

CoverageTools.LCOV Module

This module provides functionality to generate LCOV info format files from Julia coverage data. It exports the writefile function.

CoverageTools.LCOV.readfileMethod
readfile(infofile::AbstractString) -> Vector{FileCoverage}

Read coverage data from a file in LCOV info format.

CoverageTools.LCOV.readfolderMethod
readfolder(folder) -> Vector{FileCoverage}

Process the contents of a folder of LCOV files to collect coverage statistics. Will recursively traverse child folders. Post-process with merge_coverage_counts(coverages) to combine duplicates.

CoverageTools.LCOV.writeFunction
write(io::IO, fcs)

Write the given coverage data to an IO stream in LCOV info format. The data can either be a FileCoverage instance or a vector of FileCoverage instances.

CoverageTools.LCOV.writefileMethod
writefile(outfile::AbstractString, fcs)

Write the given coverage data to a file in LCOV info format. The data can either be a FileCoverage instance or a vector of FileCoverage instances.

CoverageTools.LCOV.writelineFunction
writeline(io::IO, line::Int, count)

Write LCOV data for a single line to the given IO stream. Returns a 2-tuple of the number of lines instrumented (0 or 1) and the count for how many times the line was executed during testing.

CoverageTools.FileCoverageType

FileCoverage

Represents coverage info about a file, including the filename, the source code itself, and a Vector of run counts for each line. If the line was expected to be run the count will be an Int >= 0. Other lines such as comments will have a count of nothing.

CoverageTools.amend_coverage_from_src!Method
amend_coverage_from_src!(coverage::Vector{CovCount}, srcname)
amend_coverage_from_src!(fc::FileCoverage)

The code coverage functionality in Julia only reports lines that have been compiled. Unused functions (or discarded lines) therefore may be incorrectly recorded as nothing but should instead be 0. This function takes an existing result and updates the coverage vector in-place to mark source lines that may be inside a function.

CoverageTools.analyze_malloc_filesMethod
analyze_malloc_files(files; skip_zeros::Bool = false) -> Vector{MallocInfo}

Iterates through the given list of filenames and return a Vector of MallocInfos with allocation information. If skip_zeros is true, then allocations of zero bytes are skipped.

CoverageTools.clean_fileMethod
clean_file(filename::AbstractString; include_memfiles::Bool=false)

Cleans up all .cov and optionally .mem files associated with a given source file. This only looks in the directory of the given file, i.e. the .cov/.mem files should be siblings of the source file.

CoverageTools.clean_folderMethod
clean_folder(folder::AbstractString; include_memfiles::Bool=false)

Cleans up all the .cov and optionally .mem files in the given directory and subdirectories. Unlike process_folder this does not include a default value for the root folder, requiring the calling code to be more explicit about which files will be deleted.

CoverageTools.get_summaryFunction
get_summary(fcs)

Summarize results from a single FileCoverage instance or a Vector of them, returning a 2-tuple with the covered lines and total lines.

CoverageTools.merge_coverage_countsMethod
merge_coverage_counts(as::Vector{CovCount}...) -> Vector{CovCount}

Given vectors of line coverage counts, sum together the results, preseving null counts if both are null.

CoverageTools.merge_coverage_countsMethod
merge_coverage_counts(a1::Vector{CovCount}, a2::Vector{CovCount}) -> Vector{CovCount}

Given two vectors of line coverage counts, sum together the results, preseving null counts if both are null.

CoverageTools.process_covMethod
process_cov(filename, folder) -> Vector{CovCount}

Given a filename for a Julia source file, produce an array of line coverage counts by reading in all matching .{pid}.cov files.

CoverageTools.process_fileFunction
process_file(filename[, folder]) -> FileCoverage

Given a .jl file and its containing folder, produce a corresponding FileCoverage instance from the source and matching coverage files. If the folder is not given it is extracted from the filename.

CoverageTools.process_folderFunction
process_folder(folder="src") -> Vector{FileCoverage}

Process the contents of a folder of Julia source code to collect coverage statistics for all the files contained within. Will recursively traverse child folders. Default folder is "src", which is useful for the primary case where CoverageTools is called from the root directory of a package.