1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Test builds must never write the live default home (#1399).
//!
//! Two test modules drove the onboarding wizard's voice step to its save
//! without a home override, so every full `cargo test` on a developer
//! machine rewrote the real `~/.opencrabs/config.toml` with the wizard's
//! Off defaults: eight `enabled = false` lines over the user's voice setup.
//! That was the "voice disables itself" the owner enabled eleven times in
//! one evening. The per-key writer logs every write, but a test binary logs
//! nowhere, which is why the rewrite left no fingerprint.
//!
//! The check is pure and lives here; `atomic_write` consults it only in
//! test builds. Profile-scoped test homes (`~/.opencrabs/profiles/<name>`)
//! are not the live default home and pass.
use Path;
/// `Some(reason)` when a test build is about to write a file that sits
/// directly in the live default home. Callers pass the resolved target and
/// the real base directory so the rule is testable without touching disk.
pub
/// The guard `atomic_write` applies in test builds: a no-op in a shipped
/// binary, since the release build carries no tests and users must keep
/// writing their own config.
pub