refactor(files): move file IO, watcher and link helpers into files.rs
This commit is contained in:
18
src/testutil.rs
Normal file
18
src/testutil.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
//! Test-only helpers shared by the module test suites.
|
||||
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
/// Create a unique scratch directory under the platform temp dir (the test
|
||||
/// runner points TEMP/TMP at `target\tmp`).
|
||||
pub fn temp_dir(name: &str) -> PathBuf {
|
||||
let unique = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_nanos();
|
||||
let dir =
|
||||
std::env::temp_dir().join(format!("md-preview-{name}-{}-{unique}", std::process::id()));
|
||||
fs::create_dir_all(&dir).unwrap();
|
||||
dir
|
||||
}
|
||||
Reference in New Issue
Block a user