fix(test): keep tests out of the user's config folder

Tests resolved the real per-user config dir. When the alias table
version moved, parallel tests migrated and rewrote the user's alias
file concurrently and one left it holding a single alias. Under test,
config_dir() is a per-process temp folder and the alias table comes
from the shipped defaults with no file I/O.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-09-24 15:37:00 +03:00
1 parent 163763c42a
commit eae5662099
2 files changed
+12

No files matched your search

+7
View File
@@ -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<PathBuf> {
// 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") {