From a99f481a686da07e91bedbf6c27d5fa3a71f1892 Mon Sep 17 00:00:00 2001 From: Louis Merlin Date: Wed, 7 Jan 2026 13:25:59 +0100 Subject: [PATCH] Fix profraw generation bug --- src/bin/cargo-ziggy/coverage.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/bin/cargo-ziggy/coverage.rs b/src/bin/cargo-ziggy/coverage.rs index 155cc43..165113e 100644 --- a/src/bin/cargo-ziggy/coverage.rs +++ b/src/bin/cargo-ziggy/coverage.rs @@ -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() @@ -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))?;