#![allow(dead_code)]
use std::path::{Path, PathBuf};
pub const TOY_CHILD_ENV: &str = "CORTIQ_DECISION_TEST_CHILD";
pub fn toy_dir(tag: &str) -> PathBuf {
let profile = if cfg!(debug_assertions) {
"debug"
} else {
"release"
};
let child = if std::env::var_os(TOY_CHILD_ENV).is_some() {
"-child"
} else {
""
};
let dir = Path::new(env!("CARGO_TARGET_TMPDIR"))
.join("decision-toys")
.join(format!(
"{}-{profile}-{tag}{child}",
env!("CARGO_CRATE_NAME")
));
match std::fs::remove_dir_all(&dir) {
Ok(()) => {}
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
Err(e) => panic!("remove {}: {e}", dir.display()),
}
std::fs::create_dir_all(&dir).unwrap_or_else(|e| panic!("create {}: {e}", dir.display()));
dir
}