| Crates.io | llvm-cov-json |
| lib.rs | llvm-cov-json |
| version | 0.1.2 |
| created_at | 2024-02-06 09:22:52.928272+00 |
| updated_at | 2024-07-08 12:24:50.551429+00 |
| description | A library capable of parsing llvm-cov JSON exports. |
| homepage | |
| repository | https://github.com/nbars/llvm-cov-json-rs |
| max_upload_size | |
| id | 1128598 |
| size | 31,775,728 |
This library can parse llvm-cov reports exported as JSON.
Such JSON exports are typically created by using the following command:
# Dump JSON export to stdout.
llvm-cov export --format=text --instr-profile <profile-data>
For more details on LLVM's source code-based coverage, see here.
For Rust projects, they can be created using cargo-llvm-cov using the following command:
cargo llvm-cov test
# Dump JSON export to stdout.
cargo llvm-cov report --json
use std::fs;
use llvm_cov_json::{CoverageReport};
let json_data = fs::read_to_string("coverage-report.json").unwrap()
let report: CoverageReport = serde_json::from_str(&json_data).unwrap();
/// Get the total count of branches from the summary.
let summary_branch_count = report.data[0].summary.branches.count;
println!("summary_branch_count: {}", summary_branch_count);