use std::path::PathBuf;
pub struct Fixture {
pub root: PathBuf,
_directory: crate::testing::FixtureDirectory,
}
impl Fixture {
pub fn new() -> Self {
let directory =
crate::testing::FixtureDirectory::new(&std::env::temp_dir(), "ic-host-fs-test")
.expect("create test fixture");
let root = directory.path().to_path_buf();
Self {
root,
_directory: directory,
}
}
}
#[cfg(unix)]
pub fn create_fifo(path: &std::path::Path, permissions: Option<u32>) -> std::io::Result<()> {
let mut command = std::process::Command::new("/usr/bin/mkfifo");
command.env_clear();
if let Some(permissions) = permissions {
command.args(["-m", &format!("{permissions:o}")]);
}
let status = command.arg(path).status()?;
if status.success() {
Ok(())
} else {
Err(std::io::Error::other(format!(
"FIFO fixture creation failed: {status}"
)))
}
}