diff --git a/src/app/alias.rs b/src/app/alias.rs index 350c95c67..0f47f5b1e 100644 --- a/src/app/alias.rs +++ b/src/app/alias.rs @@ -35,6 +35,11 @@ const DEFAULT_ALIASES_PGP: &str = include_str!("../../assets/ocad.pgp"); /// config base can't be resolved (headless, no `HOME`). #[cfg(not(target_arch = "wasm32"))] fn alias_file_path() -> Option { + // Tests read the shipped defaults: parallel tests seeding and migrating one + // shared file race, and a half-written table fails unrelated alias tests. + if cfg!(test) { + return None; + } Some(crate::config::config_dir()?.join("ocad.pgp")) } diff --git a/src/config.rs b/src/config.rs index e8f907441..6d1e60962 100644 --- a/src/config.rs +++ b/src/config.rs @@ -10,6 +10,13 @@ use std::path::PathBuf; /// file name onto it and `create_dir_all` its parent before writing. #[cfg(not(target_arch = "wasm32"))] pub fn config_dir() -> Option { + // Tests must never read or write the person's real settings: a test run + // once raced dozens of tests through an alias-table migration and left the + // user's alias file holding a single line. Every store routes through here, + // so one per-process scratch folder isolates them all. + if cfg!(test) { + return Some(std::env::temp_dir().join(format!("ocs-test-config-{}", std::process::id()))); + } let base: PathBuf = if cfg!(target_os = "windows") { std::env::var_os("APPDATA").map(PathBuf::from)? } else if cfg!(target_os = "macos") {