pub mod clock;
pub mod environment;
pub mod err;
pub mod file;
pub mod interaction;
pub mod random;
pub mod resources;
pub mod settings;
#[cfg(test)]
pub(crate) mod test_support {
use std::path::Path;
use std::sync::Mutex;
pub(crate) static TEST_LOCK: Mutex<()> = Mutex::new(());
pub(crate) fn lock_test() -> std::sync::MutexGuard<'static, ()> {
TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner())
}
pub(crate) fn position_of(name: &str) -> usize {
let mut i = 1;
while let Some(entry) = super::environment::env_at(i) {
if entry.starts_with(&format!("{name}=")) {
return i;
}
i += 1;
}
panic!("{name} not found in environment snapshot");
}
pub(crate) fn with_temp_settings_store<T>(f: impl FnOnce(&Path) -> T) -> T {
let _guard = lock_test();
let dir = tempfile::tempdir().expect("failed to create temp dir");
super::settings::set_store_root(dir.path());
let result = f(dir.path());
super::settings::reset_store_root();
result
}
}