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
//! Shared fixtures for the `rag-rat` CLI integration tests.
//!
//! Every git fixture repo built here gets a DETERMINISTIC, wall-clock-independent commit identity,
//! so two fixtures built in the same test process can never share a root commit. rag-rat's portable
//! `repo_id` is the smallest root-commit hash; identical fixture content committed on the system
//! clock (1-second granularity, no `GIT_*_DATE`) used to produce byte-identical root commits →
//! the SAME `repo_id`, and two such fixtures landing in one consolidated/global DB collided (#434).
//!
//! The commit date is a fixed base epoch plus a per-commit counter — the SAME atomic that keys
//! temp-dir uniqueness — so fixture identities are both DISTINCT across fixtures and REPRODUCIBLE
//! across runs (stable hashes, independent of CI load). No sleeps, retries, or `--no-verify`.
//!
//! Not every integration binary uses every helper here; `#![allow(dead_code)]` keeps the shared
//! module warning-clean under `clippy --all-targets -D warnings`.
use fs;
use ;
use Command;
use ;
/// 2021-01-01T00:00:00Z — a fixed, wall-clock-independent anchor for fixture commit dates.
const FIXTURE_EPOCH_BASE: u64 = 1_609_459_200;
/// One process-wide counter drives BOTH temp-dir names and fixture commit dates, so every fixture
/// gets a unique path AND a unique, reproducible root-commit hash. nextest runs each test in its
/// own process, so the call order — and thus the assigned counters — is deterministic per test.
static SEQ: AtomicU64 = new;
/// A throwaway temp dir under the system temp root, keyed by `tag`, the process id, and a unique
/// counter. Any stale dir at the path is removed first.
/// A filesystem path formatted for embedding inside a double-quoted TOML string value. On Windows a
/// raw `db.display()` yields `C:\Users\…`, whose `\U`/`\R`/… are invalid TOML escape sequences
/// (`too few unicode value digits` at parse). `to_slash_lossy` (path-slash) rewrites the SEPARATOR
/// to `/` on Windows — TOML-safe, and `Path` treats `/`≡`\` there so the parsed config still equals
/// the original `PathBuf` — while leaving a literal backslash in a Unix filename intact.
/// Run `git -C dir args`, asserting success. Use [`git_commit`] for commits so the commit carries a
/// deterministic, unique date (a plain `git(dir, &["commit", ...])` would commit on the wall clock
/// and could collide on `repo_id`).
/// `git commit` with `GIT_AUTHOR_DATE`/`GIT_COMMITTER_DATE` pinned to a fixed base epoch plus a
/// unique counter, so two fixtures with identical content never share a root-commit hash (and thus
/// never collide on the portable `repo_id`), while the hashes stay reproducible across runs. `args`
/// are the commit flags/message, e.g. `&["-q", "-m", "seed"]`.