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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! Shared test helpers that keep the git-command tests LAYOUT-AGNOSTIC
//! (V37): the enclosing repo root and this crate's path prefix come from
//! git at RUNTIME, so one test passes both at `<repo>/crates/itok` and when
//! the crate is the extracted repo root. Hardcoding `parent().parent()` as
//! the root or a `crates/itok/...` pathspec couples a test to the monorepo
//! layout and breaks the extraction rehearsal (B2/T11).
const DIR: &str = env!;
/// A host for tests that need one, defined ONCE so no test carries a real
/// address. `192.0.2.x` is TEST-NET-1 (RFC 5737), reserved for
/// documentation and guaranteed never routable -- so this cannot become a
/// real machine later, which a plausible-looking LAN address can.
///
/// NOT read from `OLLAMA_HOST`, deliberately, and the distinction matters.
/// That variable is the RUNTIME resolution chain (V22) and belongs in
/// `ollama::hosts`. A test that read it would take its input from the
/// machine it happens to run on, which is exactly the ambient-state
/// coupling B3 was about -- the same test would then assert different
/// things on two developers' laptops. These tests want a fixed string; what
/// they check is an identity (`--ollama=X` yields host `X`) and a
/// difference (two hosts must render differently), and neither depends on
/// the value being anyone's real endpoint.
pub const HOST_IP: &str = "192.0.2.10";
/// A second address, for the tests that must show two hosts differing.
pub const HOST_IP_ALT: &str = "192.0.2.20";
/// A bare hostname, for the `=`-form and default-port paths. `.invalid` is
/// reserved by RFC 2606 and can never resolve.
pub const HOST_NAME: &str = "tokhost.invalid";
/// Whether the DOGFOOD tests may run: the ones that read THIS repo's own
/// git history -- tracked set, blobs at HEAD, `HEAD~1..HEAD` -- rather than
/// a fixture. They need a git repo WITH history at `CARGO_MANIFEST_DIR`,
/// and the published `.crate` is neither: a consumer's registry source dir
/// has no `.git` at all. `cargo package --verify` never caught it because
/// it only COMPILES the tarball, so the miss survived to a dry run (B17).
///
/// An ENV gate, not a silent `is this a repo` probe, and the difference is
/// the whole point. Auto-skipping would go green in the repo too, the day
/// something breaks git detection -- a suite that reports success for the
/// reason it should have reported failure. Requiring the variable makes
/// the skip a DECISION someone made: unset means "not the dogfood
/// environment", and the repo's own gate sets it (`hk.pkl`, `flake.nix`).
///
/// Vendorers are why the gate cannot key off repo presence either: a
/// consumer who vendors this source INTO their git repo would satisfy any
/// such probe and then fail on our history. They will never set this.
pub
/// The enclosing git repo's root (`git rev-parse --show-toplevel`): the
/// monorepo root in-tree, the crate dir once extracted.
pub
/// A repo-root-relative path to one of this crate's own files:
/// `crates/itok/SPEC.md` in the monorepo, `SPEC.md` when extracted
/// (`git rev-parse --show-prefix` yields the crate's prefix, empty at the
/// repo root).
pub
/// The tool's own scrubbed constructor, not a bare `Command`: `-C` loses to
/// an inherited `GIT_DIR`, and this suite runs from `pre-commit`, where git
/// has exported one (B19). Unscrubbed, `repo_root` answers with the
/// INVOKING repository and every caller inherits the wrong answer.