Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mandragorian committed Oct 26, 2024
1 parent 7c05218 commit b2c45a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl Command {
bless,
flags,
target,
coverage.then_some(crate::coverage::CoverageReport::new()?),
coverage,
),
Command::Run { dep, verbose, many_seeds, target, edition, flags } =>
Self::run(dep, verbose, many_seeds, target, edition, flags),
Expand Down Expand Up @@ -468,10 +468,12 @@ impl Command {
bless: bool,
mut flags: Vec<String>,
target: Option<String>,
coverage: Option<crate::coverage::CoverageReport>,
coverage: bool,
) -> Result<()> {
let mut e = MiriEnv::new()?;

let coverage = coverage.then_some(crate::coverage::CoverageReport::new()?);

if let Some(report) = &coverage {
report.add_env_vars(&mut e)?;
}
Expand Down
10 changes: 5 additions & 5 deletions miri-script/src/coverage.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::ffi::OsString;
use std::path::PathBuf;

use anyhow::{Context, Result};
use path_macro::path;
Expand Down Expand Up @@ -57,8 +57,7 @@ impl CoverageReport {
let merged_file = path!(e.miri_dir / "target" / "coverage.profdata");

// Merge the profraw files
let profraw_files_cloned = profraw_files.iter();
cmd!(e.sh, "{profdata_bin} merge -sparse {profraw_files_cloned...} -o {merged_file}")
cmd!(e.sh, "{profdata_bin} merge -sparse {profraw_files...} -o {merged_file}")
.quiet()
.run()?;

Expand All @@ -72,6 +71,7 @@ impl CoverageReport {
)
.run()?;

println!("Profile data saved in {}", merged_file.display());
Ok(())
}

Expand All @@ -80,12 +80,12 @@ impl CoverageReport {
/// # Errors
///
/// An error will be returned if `self.path` can't be read.
fn profraw_files(&self) -> Result<Vec<OsString>> {
fn profraw_files(&self) -> Result<Vec<PathBuf>> {
Ok(std::fs::read_dir(&self.path)?
.filter_map(|r| r.ok())
.filter(|e| e.file_type().is_ok_and(|t| t.is_file()))
.map(|e| e.path())
.filter(|p| p.extension().is_some_and(|e| e == "profraw"))
.map(|p| p.as_os_str().to_os_string())
.collect())
}
}

0 comments on commit b2c45a4

Please sign in to comment.