Skip to content

Commit

Permalink
Fix coverage with new runner
Browse files Browse the repository at this point in the history
  • Loading branch information
louismerlin committed Dec 16, 2024
1 parent ac11b77 commit 93f7003
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/bin/cargo-ziggy/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,35 @@ impl Cover {
Cover::clean_old_cov()?;
}

let mut shared_corpus = PathBuf::new();

shared_corpus.push(
let input_path = PathBuf::from(
self.input
.display()
.to_string()
.replace("{ziggy_output}", &self.ziggy_output.display().to_string())
.replace("{target_name}", &self.target)
.as_str(),
.replace("{target_name}", &self.target),
);

let _ = process::Command::new(format!("./target/coverage/debug/{}", &self.target))
.arg(format!("{}", shared_corpus.display()))
.env(
"LLVM_PROFILE_FILE",
"target/coverage/debug/deps/coverage-%p-%m.profraw",
)
.spawn()
.unwrap()
.wait_with_output()
.unwrap();
let coverage_corpus = match input_path.is_dir() {
true => fs::read_dir(input_path)
.unwrap()
.flatten()
.map(|e| e.path())
.collect(),
false => vec![input_path],
};

for file in coverage_corpus {
let _ = process::Command::new(format!("./target/coverage/debug/{}", &self.target))
.arg(file.display().to_string())
.env(
"LLVM_PROFILE_FILE",
"target/coverage/debug/deps/coverage-%p-%m.profraw",
)
.spawn()
.unwrap()
.wait_with_output()
.unwrap();
}

let source_or_workspace_root = match &self.source {
Some(s) => s.display().to_string(),
Expand Down

0 comments on commit 93f7003

Please sign in to comment.