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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! Cross-platform shell-check command builders for coder tests.
//!
//! The coder runs a check / goal command through its shell tool — `sh -lc` on
//! Unix, `cmd /C` on Windows — so a test fixture must not hard-code POSIX-only
//! commands (`grep`, `true`, `false`, `cat`, `test -f`); those fail with
//! `'grep' is not recognized` on Windows and take the whole scripted loop with
//! them. Each builder emits the shell-appropriate equivalent for the current
//! target so the same fixture verifies identically on every OS.
/// Absolute path to a Windows System32 utility, for commands that are NOT `cmd`
/// builtins.
///
/// **Do not shorten these to a bare program name.** `PATH` on a Windows box is
/// not guaranteed to contain `C:\Windows\System32` — the GitHub `windows-latest`
/// runner is one that doesn't. `cmd.exe` itself still launches there, because
/// Windows' `CreateProcess` falls back to the system directory when resolving a
/// program name, but `cmd`'s *own* lookup for an external command consults only
/// `%PATH%` — so a bare `findstr` / `ping` dies with "'findstr' is not
/// recognized" while every builtin (`exit`, `if exist`, `type`) works fine. That
/// asymmetry is exactly what broke these fixtures in CI while they passed
/// locally. `%SystemRoot%` is expanded by `cmd`, so this needs no PATH lookup.
///
/// Defined unconditionally (not `#[cfg(windows)]`) because the callers select
/// with a runtime `cfg!(windows)`, so the call is compiled on every platform.
/// A command that always succeeds (exit 0). `exit` is a builtin of both `sh`
/// and `cmd`, so this literal is portable — no per-OS branch needed.
pub const PASS: &str = "exit 0";
/// A command that always fails (exit 1). Portable for the same reason as
/// [`PASS`].
pub const FAIL: &str = "exit 1";
/// Succeeds iff `file` exists — POSIX `test -f`, cmd `if exist`.
pub
/// Prints the contents of `file` — POSIX `cat`, cmd `type`. Pair with a
/// `output_contains` assertion for a content check that streams the file.
pub
/// Succeeds iff `file` contains the literal `needle` — POSIX `grep`, cmd
/// `findstr`. Case-sensitive on both (matching `grep -q`, not `grep -qi`).
///
/// **`needle` must be a single whitespace-free token.** The command is handed to
/// `cmd /C <arg>` on Windows, and a quoted `findstr /C:"…"` can't survive that
/// round-trip — Rust re-quotes the whole arg and `cmd` mangles the inner quotes
/// (`FINDSTR: Cannot open …`). A bare, unquoted findstr search string is a
/// single literal token, so fixtures pick one distinctive word of the expected
/// content instead of the whole phrase.
pub
/// Like [`contains`], but on failure prints `assertion failed` before exiting
/// non-zero. A failing check's output feeds the repair-learning failure
/// signature, so the fixture needs a stable, recognizable failure message on
/// both shells — not just findstr/grep's silent exit code.
pub
/// Creates (or touches) an empty `file` — POSIX `touch`, cmd `type nul >`.
/// Used by goal fixtures whose scripted model "creates a file", where the
/// deterministic goal check then asserts the file exists on disk.
pub
/// Prints the working directory — POSIX `pwd`, cmd `cd` (with no argument, `cd`
/// echoes the current directory rather than changing it).
pub
/// A command that blocks for roughly `secs` seconds without needing a console or
/// stdin — POSIX `sleep`, Windows `ping` loopback delay (`timeout` refuses a
/// redirected stdin, which the coder shell always supplies). Used by cancel /
/// timeout fixtures that need a long-running child to interrupt.
pub