CoverageTools.LCOV
— ModuleCoverageTools.LCOV Module
This module provides functionality to generate LCOV info format files from Julia coverage data. It exports the writefile
function.
CoverageTools.LCOV.readfile
— Methodreadfile(infofile::AbstractString) -> Vector{FileCoverage}
Read coverage data from a file in LCOV info format.
CoverageTools.LCOV.readfolder
— Methodreadfolder(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.write
— Functionwrite(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.writefile
— Methodwritefile(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.writeline
— Functionwriteline(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.FileCoverage
— TypeFileCoverage
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!
— Methodamend_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_files
— Methodanalyze_malloc_files(files; skip_zeros::Bool = false) -> Vector{MallocInfo}
Iterates through the given list of filenames and return a Vector
of MallocInfo
s with allocation information. If skip_zeros
is true
, then allocations of zero bytes are skipped.
CoverageTools.clean_file
— Methodclean_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_folder
— Methodclean_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_summary
— Functionget_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_counts
— Methodmerge_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_counts
— Methodmerge_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_cov
— Methodprocess_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_file
— Functionprocess_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_folder
— Functionprocess_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.