load coverage file from environment variable

pull/10758/head
Dustin Lagoy 2024-05-09 07:18:01 -07:00
parent 6006a69b44
commit 79b85030b2
1 changed files with 29 additions and 27 deletions

View File

@ -151,35 +151,37 @@ pub fn coverage<'doc>(
) -> GutterFn<'doc> {
let covered = theme.get("diff.plus.gutter");
let not_covered = theme.get("diff.minus.gutter");
if let Some(cov) = coverage::parse(PathBuf::from("report/coverage.xml")) {
if let Some(mut path) = doc.path.clone() {
if let Ok(cwd) = std::env::current_dir() {
if let Ok(tmp) = path.strip_prefix(cwd) {
path = tmp.into();
if let Ok(coverage_path) = std::env::var("HELIX_COVERAGE_FILE") {
if let Some(cov) = coverage::parse(PathBuf::from(coverage_path)) {
if let Some(mut path) = doc.path.clone() {
if let Ok(cwd) = std::env::current_dir() {
if let Ok(tmp) = path.strip_prefix(cwd) {
path = tmp.into();
}
}
}
if let Some(file) = cov.files.get(&path) {
let this_file = coverage::FileCoverage {
lines: file.lines.clone(),
};
return Box::new(
move |line: usize,
_selected: bool,
_first_visual_line: bool,
out: &mut String| {
if let Some(line_coverage) = this_file.lines.get(&(line as u32)) {
let (icon, style) = if *line_coverage {
("", covered)
if let Some(file) = cov.files.get(&path) {
let this_file = coverage::FileCoverage {
lines: file.lines.clone(),
};
return Box::new(
move |line: usize,
_selected: bool,
_first_visual_line: bool,
out: &mut String| {
if let Some(line_coverage) = this_file.lines.get(&(line as u32)) {
let (icon, style) = if *line_coverage {
("", covered)
} else {
("", not_covered)
};
write!(out, "{}", icon).unwrap();
Some(style)
} else {
("", not_covered)
};
write!(out, "{}", icon).unwrap();
Some(style)
} else {
None
}
},
);
None
}
},
);
}
}
}
}