diff --git a/src/app/config.rs b/src/app/config.rs index b22e28e70..6d1c8f0eb 100644 --- a/src/app/config.rs +++ b/src/app/config.rs @@ -460,7 +460,16 @@ impl AppConfig { /// Persist the config as JSON. Best-effort; silent on unavailable or /// read-only storage. + /// + /// Does nothing under `cfg(test)`. The path is the developer's own + /// settings file, and the suite builds whole applications and changes + /// preferences on them — without this, running `cargo test` rewrites the + /// settings of whoever ran it. pub fn save(&self) { + if cfg!(test) { + return; + } + #[cfg(not(target_arch = "wasm32"))] { let Some(path) = config_path() else { return }; diff --git a/src/app/mod.rs b/src/app/mod.rs index 9269c3b3d..eef45d546 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -3856,7 +3856,16 @@ impl OpenCADStudio { #[cfg(test)] pub(crate) fn new_for_test() -> Self { - Self::new() + let mut app = Self::new(); + // `new` loads the real settings file, so without this every test runs + // against whatever the developer last set in the application — a suite + // that passes on a clean machine and fails on a used one. It surfaced + // when a persisted `GRIPOBJLIMIT` made the grip-limit test see 32767 + // where it expected the default, and the number of persisted settings + // only grows. + app.apply_config(crate::app::config::AppConfig::default()); + app.last_saved_config = Some(app.current_config()); + app } /// Install `cmd` as the active interactive command for tab `tab`.