Expand description
A library for generating and writing LCOV files, and converting them to HTML format.
§Examples
§Writing an LCOV file
This example will write an info file with a single record for a test file with two lines and a single function. (imagine main() has a lot of empty space!)
ⓘ
use lcov::{Records, Record};
use std::fs::write;
let mut records = Records::default();
let test_record = records.get_or_insert_mut(Path::new("/path/to/test.c"));
test_record.add_function_if_not_exists(1, 32, "main");
test_record.increment_function_data("main");
test_record.add_line_if_not_exists(1);
test_record.add_line_if_not_exists(32);
test_record.increment_line(1);
test_record.increment_line(32);
write("test.info", records.to_string()).unwrap();
§Reading an LCOV file
This example will read an info file.
ⓘ
use lcov::Records;
use std::fs::read_to_string;
let contents = read_to_string("test.info").unwrap();
let records = Records::from_str(&contents).unwrap();
§Generating an HTML report
This example will generate an HTML report from the records in a format that looks very much like LCOV style (not an exact match).
ⓘ
use lcov::Records;
use std::fs::{read_to_string, write};
let contents = read_to_string("test.info").unwrap();
let records = Records::from_str(&contents).unwrap();
write("test.html", records.to_html().unwrap()).unwrap();
Modules§
Structs§
- Branch
Data Record Entry - Branch coverage information
- Branches
Found Record Entry - The number of branches found
- Branches
HitRecord Entry - The number of branches hit
- EndOf
Record Entry - The end of the record section
- Function
Data Record Entry - A list of execution counts for each instrumented function
- Function
Record Entry - A list of line numbers for each function name found in the source file
- Functions
Found Record Entry - The number of functions found
- Functions
HitRecord Entry - The number of functions hit
- Line
Record Entry - Execution count for an instrumented line (i.e. a line which resulted in executable code – there may not be a record for every source line)
- Lines
Found Record Entry - Number of instrumented lines
- Lines
HitRecord Entry - Number of lines with a non-zero execution count
- Record
- A single record section, which contains information about a single source file for a single test
- Records
- A collection of record sections read from a file
- Source
File Record Entry - For each source file referenced in the .gcda file, there is a section containing filename and coverage data
- Test
Name Record Entry - If available, a tracefile begins with the testname
- Version
Record Entry - An optional source code version ID