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
//! Cross-platform helpers that every shell-integration test needs:
//! locating the runex binary, writing a config file, and checking
//! whether a particular shell is on `PATH`.
use Write;
use ;
use NamedTempFile;
/// Absolute path to the freshly-built `runex` binary for this test
/// crate. Cargo sets `CARGO_BIN_EXE_<name>` for every `[[bin]]` in
/// the parent crate, so this is build-system-correct without any
/// path walking.
/// Same as [`runex_bin`] but as `&'static str`. Useful when the
/// caller needs to format it into a shell command via `format!`,
/// where `Path::display()` would add a borrow that complicates the
/// type story.
/// Write `toml` to a fresh `NamedTempFile` and return it. The file
/// is deleted when the returned handle drops, so the caller must
/// keep it alive for the duration of any subprocess that reads from
/// `RUNEX_CONFIG`.
///
/// `toml` is taken verbatim — no `version = 1` is prepended; tests
/// that need different schema versions write their own header.
/// Convenience overload: write a single-abbr config that maps `key`
/// to `expand`, with the trigger key explicitly set to `space` for
/// every shell. The default-config path infers `space` too, but PTY-
/// driven tests are sensitive to the `[keybind.trigger]` header
/// being absent (the integration script's keymap won't bind the
/// trigger), so we make it explicit. The cost is one extra TOML
/// section in tests that don't care; the benefit is that tests
/// don't silently no-op if default-trigger plumbing changes.
/// Write `toml` to a named path under `dir`. Unlike [`write_config_file`]
/// this returns a `PathBuf` (no auto-cleanup) and is intended for tests
/// that need a stable, predictable path — e.g. when a subprocess will
/// later look up the file by name from a hardcoded directory.
/// Returns `true` iff `shell` resolves on the current `PATH`. The
/// shell-specific tests use this for runtime skip guards: a Linux CI
/// runner without zsh installed should silently skip the zsh suite
/// rather than fail.
///
/// Identical semantics to `which::which(shell).is_ok()` — wrapping it
/// here keeps `which` out of every test crate's import list.
/// Returns `true` iff bash is available **and** is at least version 4.
/// macOS ships bash 3.2 (GPLv2 cut-off) which lacks the readline
/// features the runex bash integration depends on. Tests that source
/// the integration script must skip on bash 3.x.
///
/// `$BASH_VERSION` looks like `"5.2.37(1)-release"`; we parse only
/// the major version.