Expand description
A coverage summary bound to the commit and tree it was measured on.
scripts/rust-coverage --summary-json writes what one coverage run measured: the crate,
the session domain and every file, as covered and total counts per dimension. The file
names no commit, so on its own it is a number about some tree nobody can name. An
EvidenceCoverage is that summary with the commit it was measured at and the tree the
run’s own measurement stated, and it cannot be built without a full commit
(CommitId). It carries the floors the threshold files state at recording time, read
from the files rather than copied, so a reader can see whether the measurement met them.
A coverage record is current only for its own commit, and only when both its tree and the presented tree are clean: a number measured on a modified checkout describes code no commit holds.
§A coverage record’s lifecycle
use majordomus_cli::evidence::{CommitId, EvidenceCoverage, EvidenceCoverageFloors, TreeState};
let dims = r#"{"lines":{"covered":8,"total":10,"percent":80.0},
"functions":{"covered":1,"total":1,"percent":100.0},
"regions":{"covered":3,"total":4,"percent":75.0}}"#;
let summary = format!(
r#"{{"schema":1,"measurement":"scripts/rust-coverage","test_code":"excluded",
"crate":{dims},"domain":{{"lines":{{"covered":8,"total":10,"percent":80.0}},
"functions":{{"covered":1,"total":1,"percent":100.0}},
"regions":{{"covered":3,"total":4,"percent":75.0}},"files":["src/a.rs"],"missing":[]}},
"files":{{"src/a.rs":{dims}}}}}"#
);
let commit = CommitId::parse("0123456789abcdef0123456789abcdef01234567").unwrap();
let floors = EvidenceCoverageFloors { crate_lines: Some(90.0), domain_lines: None };
let cov = EvidenceCoverage::from_summary(&summary, commit, TreeState::Clean, floors).unwrap();
assert!(cov.is_current_for("0123456789abcdef0123456789abcdef01234567", TreeState::Clean));
assert!(!cov.is_current_for("0123456789abcdef0123456789abcdef01234567", TreeState::Dirty));
assert!(!cov.is_current_for("fedcba9876543210fedcba9876543210fedcba98", TreeState::Clean));
assert_eq!(cov.below_floor(), vec!["crate"]);Structs§
- Commit
Id - A full commit id: 40 or 64 lowercase hexadecimal digits. The only constructor validates.
- Evidence
Coverage - One coverage measurement, bound to the commit and tree it was measured on.
- Evidence
Coverage Count - Covered and total items of one dimension, and the percentage the producer computed.
- Evidence
Coverage Dimensions - The three dimensions
scripts/rust-coveragecounts, for the crate or one file. - Evidence
Coverage Domain - The session domain’s coverage: the three dimensions over the files the domain lists, and which of its files the measurement found and which it did not.
- Evidence
Coverage Floors - The floors the threshold files stated when the coverage was recorded; a file that is absent or does not hold a number gives no floor.