LCOV report parser for Rust.
Create a LCOVParser object, and then parse the data.
```rust extern crate lcov_parser;
use lcov_parser:: { LCOVParser, LCOVRecord };
fn main() { let content = concat!( "TN:testname\n", "SF:/path/to/source.rs\n", "DA:1,2\n", "DA:2,1\n", "DA:3,5\n", "endofrecord\n" ); let mut parser = LCOVParser::new(content.asbytes());
loop {
match parser.next().expect("parse the report") {
None => { break; },
Some(record) => match record {
LCOVRecord::TestName(name) => println!("Test: {}", name.unwrap()),
LCOVRecord::SourceFile(file_name) => println!("File: {}", file_name),
LCOVRecord::Data(data) => println!("Line: {}, Executed: {}", data.line, data.count),
LCOVRecord::EndOfRecord => println!("Finish"),
_ => { continue; }
}
}
}
} ```
It can also be used to parse the report file.
```rust let mut parser = LCOVParser::from_file("../../../fixture/report.lcov").unwrap();
loop { match parser.next().expect("parse the report") { None => { break; }, Some(record) => match record { LCOVRecord::SourceFile(filename) => println!("File: {}", filename), LCOVRecord::EndOfRecord => println!("Finish"), _ => { continue; } } } } ```
You can parse all using the parse method.
```rust let records = { let mut parser = LCOVParser::from_file("../../../fixture/report.lcov").unwrap(); parser.parse().expect("parse the report") };
for record in records.iter() { match record { &LCOVRecord::SourceFile(ref filename) => println!("File: {}", filename), &LCOVRecord::EndOfRecord => println!("Finish"), _ => { continue; } } } ```
You use merge_files to merge reports.
You can save the merged report by specifying the file name.
```rust extern crate lcov_parser;
use lcovparser:: { mergefiles };
fn main() { let tracefiles = [ "../../../tests/fixtures/fixture1.info", "../../../tests/fixtures/fixture2.info" ]; let _ = match mergefiles(&tracefiles) { Ok(report) => report.saveas("/tmp/merged_report.info"), Err(err) => panic!(err) }; } ```
Licensed under either of * Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) * MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.