allow class lines to be optional in coverage xml

This commit is contained in:
Dustin Lagoy 2025-04-03 10:02:04 -07:00
parent e8aa25e332
commit aa144e68c6

View file

@ -60,7 +60,7 @@ struct Class {
name: String, name: String,
#[serde(rename = "@filename")] #[serde(rename = "@filename")]
filename: String, filename: String,
lines: Lines, lines: Option<Lines>,
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@ -148,9 +148,11 @@ impl From<RawCoverage> for Coverage {
for package in coverage.packages.package { for package in coverage.packages.package {
for class in package.classes.class { for class in package.classes.class {
let mut lines = HashMap::new(); let mut lines = HashMap::new();
for line in class.lines.line { if let Some(class_lines) = class.lines {
for line in class_lines.line {
lines.insert(line.number - 1, line.hits > 0); lines.insert(line.number - 1, line.hits > 0);
} }
}
for source in &coverage.sources.source { for source in &coverage.sources.source {
// it is ambiguous to which source a coverage class might belong // it is ambiguous to which source a coverage class might belong
// so check each in the path // so check each in the path