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
//! An in-process stand-in for the git child.
//!
//! Two things need it. The rules in [`super`] classify answers a real repository
//! is awkward to produce on demand — a look that warns while printing nothing, a
//! wrapper that exits 1 with a diagnostic, a child a signal killed — and the
//! shell shims that produced them in `tests/check.rs` run on unix only. And a
//! caller that gates one read on another is only shown to gate by observing that
//! the second child never ran, which a real repository cannot report.
use Mutex;
use Reply;
/// An answer and the operation that earns it, named by [`super::OpShape::name`].
/// Answers keyed by operation rather than by position.
///
/// Keying matters twice over. A positional queue answers whatever is asked, so
/// a caller that spawns the wrong child still gets a reply and the test still
/// passes. And position makes every answer an obligation: a test cannot script
/// the child a gate is meant to prevent, because the gate holding would shift
/// every later answer onto the wrong read. Keyed, an unclaimed answer is one
/// the caller was right not to ask for — which is why nothing here complains
/// about leftovers. What a caller did ask for is [`Fake::asked`], which a test
/// asserts on directly.
///
/// The key is the operation's name, not its argv. An argv key would put git's
/// flags in every caller's test, where a changed flag breaks a test that has
/// nothing to do with it, and matching one would need rules about how much of a
/// command line counts. The names are distinct, stable, and already the phrase
/// a failure quotes, so a script reads as the diagnostics it stands for.
///
/// `Mutex` rather than `RefCell` so a scripted [`super::Git`] stays `Sync` like
/// the shipping one, instead of changing shape under `cfg(test)`.
pub