Skip to content

Commit 736d3c1

Browse files
committed
Make make_temp_dir() work on Windows
1 parent 4805a7b commit 736d3c1

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

collector/src/execute.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,15 +1114,25 @@ impl Benchmark {
11141114
self.config.supports_stable
11151115
}
11161116

1117+
#[cfg(windows)]
1118+
fn copy(from: &Path, to: &Path) -> anyhow::Result<()> {
1119+
robocopy(from, to, &[])
1120+
}
1121+
1122+
#[cfg(unix)]
1123+
fn copy(from: &Path, to: &Path) -> anyhow::Result<()> {
1124+
let mut cmd = Command::new("cp");
1125+
cmd.arg("-pLR").arg(from).arg(to);
1126+
command_output(&mut cmd)
1127+
}
1128+
11171129
fn make_temp_dir(&self, base: &Path) -> anyhow::Result<TempDir> {
11181130
// Appending `.` means we copy just the contents of `base` into
11191131
// `tmp_dir`, rather than `base` itself.
11201132
let mut base_dot = base.to_path_buf();
11211133
base_dot.push(".");
11221134
let tmp_dir = TempDir::new()?;
1123-
let mut cmd = Command::new("cp");
1124-
cmd.arg("-pLR").arg(base_dot).arg(tmp_dir.path());
1125-
command_output(&mut cmd).with_context(|| format!("copying {} to tmp dir", self.name))?;
1135+
Self::copy(&base_dot, tmp_dir.path()).with_context(|| format!("copying {} to tmp dir", self.name))?;
11261136
Ok(tmp_dir)
11271137
}
11281138

0 commit comments

Comments
 (0)