Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/bin/cargo-ziggy/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ impl Cover {
.as_str(),
);

// Get the absolute path for the coverage directory to ensure .profraw files
// are created in the correct location, even in workspace scenarios
let coverage_target_dir = env::current_dir()
.unwrap()
.join("target/coverage/debug/deps");
let profile_file = coverage_target_dir.join("coverage-%p-%m.profraw");

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",
)
.env("LLVM_PROFILE_FILE", profile_file.display().to_string())
.spawn()
.unwrap()
.wait_with_output()
Expand Down Expand Up @@ -142,7 +146,13 @@ impl Cover {
}

pub fn clean_old_cov() -> Result<(), anyhow::Error> {
if let Ok(profile_files) = glob("target/coverage/debug/deps/*.profraw") {
// Use absolute path to ensure we clean the correct location in workspaces
let coverage_deps_dir = env::current_dir()
.unwrap()
.join("target/coverage/debug/deps");
let pattern = coverage_deps_dir.join("*.profraw");

if let Ok(profile_files) = glob(&pattern.display().to_string()) {
for file in profile_files.flatten() {
let file_string = &file.display();
fs::remove_file(&file).context(format!("⚠️ couldn't remove {}", file_string))?;
Expand Down