use std::fs; use std::env; use std::path::PathBuf; pub fn env(key: &str) -> PathBuf { match env::var(key) { Ok(val) => PathBuf::from(val), _ => PathBuf::from(""), } } pub fn dir_does_not_exist(path: &PathBuf) { if path.exists() { remove_dir_all(path); } assert_eq!(path.exists(), false); } pub fn dir_exists(path: &PathBuf) { assert_eq!(path.exists(), true); remove_dir_all(path); assert_eq!(path.exists(), false); } fn remove_dir_all(path: &PathBuf) { match fs::remove_dir_all(path) { Ok(_val) => (), _ => panic!("Unable to remove {}", path.display()), } }