pub struct EvidenceCoverage {
pub commit: CommitId,
pub working_tree: TreeState,
pub measurement: String,
pub test_code: String,
pub whole_crate: EvidenceCoverageDimensions,
pub domain: EvidenceCoverageDomain,
pub files: BTreeMap<String, EvidenceCoverageDimensions>,
pub floors: EvidenceCoverageFloors,
}Expand description
One coverage measurement, bound to the commit and tree it was measured on.
Built only by EvidenceCoverage::from_summary or deserialised; either way commit is a
CommitId, so a record without a full commit cannot exist.
use majordomus_cli::evidence::EvidenceCoverage;
let bad = serde_json::json!({"commit": "abc", "working_tree": "clean"});
assert!(serde_json::from_value::<EvidenceCoverage>(bad).is_err());Fields§
§commit: CommitIdThe commit the measurement ran at.
working_tree: TreeStateThe tree the coverage run’s own measurement stated, unknown without one.
measurement: StringThe producer of the summary: scripts/rust-coverage.
test_code: StringWhether test code is counted: excluded.
whole_crate: EvidenceCoverageDimensionsThe whole crate.
domain: EvidenceCoverageDomainThe session domain.
files: BTreeMap<String, EvidenceCoverageDimensions>Every file with executable code under test, by repository-relative path.
floors: EvidenceCoverageFloorsThe floors stated when it was recorded.
Implementations§
Source§impl EvidenceCoverage
impl EvidenceCoverage
Sourcepub fn from_summary(
text: &str,
commit: CommitId,
working_tree: TreeState,
floors: EvidenceCoverageFloors,
) -> Result<EvidenceCoverage, String>
pub fn from_summary( text: &str, commit: CommitId, working_tree: TreeState, floors: EvidenceCoverageFloors, ) -> Result<EvidenceCoverage, String>
The summary text bound to commit and working_tree, with floors; refused when
the text is not a schema-1 summary.
use majordomus_cli::evidence::{CommitId, EvidenceCoverage, TreeState};
let id = CommitId::parse(&"a".repeat(40)).unwrap();
let err = EvidenceCoverage::from_summary(r#"{"schema":2}"#, id, TreeState::Clean,
Default::default()).unwrap_err();
assert!(err.contains("schema"), "{err}");Sourcepub fn is_current_for(&self, commit: &str, presented_tree: TreeState) -> bool
pub fn is_current_for(&self, commit: &str, presented_tree: TreeState) -> bool
Whether this measurement describes commit as presented: only its own commit, and
only when its tree and the presented tree are both clean.
let c = "b".repeat(40);
let cov = EvidenceCoverage::from_summary(&text, CommitId::parse(&c).unwrap(),
TreeState::Unknown, Default::default()).unwrap();
assert!(!cov.is_current_for(&c, TreeState::Clean), "its own tree was not measured");Sourcepub fn below_floor(&self) -> Vec<&'static str>
pub fn below_floor(&self) -> Vec<&'static str>
Which of the crate and the domain are below the line floor recorded with them.
let floors = EvidenceCoverageFloors { crate_lines: Some(40.0), domain_lines: Some(60.0) };
let cov = EvidenceCoverage::from_summary(&text, CommitId::parse(&"c".repeat(40)).unwrap(),
TreeState::Clean, floors).unwrap();
assert_eq!(cov.below_floor(), vec!["domain"]);Trait Implementations§
Source§impl Clone for EvidenceCoverage
impl Clone for EvidenceCoverage
Source§fn clone(&self) -> EvidenceCoverage
fn clone(&self) -> EvidenceCoverage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EvidenceCoverage
impl Debug for EvidenceCoverage
Source§impl<'de> Deserialize<'de> for EvidenceCoverage
impl<'de> Deserialize<'de> for EvidenceCoverage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for EvidenceCoverage
impl JsonSchema for EvidenceCoverage
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for EvidenceCoverage
impl PartialEq for EvidenceCoverage
Source§fn eq(&self, other: &EvidenceCoverage) -> bool
fn eq(&self, other: &EvidenceCoverage) -> bool
self and other values to be equal, and is used by ==.