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
//! A `true`/`false` literal passed as the *value* of a value-taking flag must
//! survive to the builtin, not be swallowed by bool-flagify.
//!
//! `spawn --command true` lexes `true` as `Value::Bool(true)`; the old
//! `flagify_bool_named` moved any bool-valued named entry into the flag set, so
//! `--command` arrived with no value and clap errored "a value is required".
//! Now flagify skips keys the schema declares value-taking, so the literal
//! command `true` reaches spawn.
//!
//! `spawn` is `subprocess`-gated, so this binary only exercises the fix when
//! that feature is on (it is under `cargo test --all` via workspace feature
//! unification; a bare `-p kaish-kernel` run compiles it to nothing).
#![cfg(feature = "subprocess")]
mod common;
use common::kernel_at;
#[tokio::test]
async fn spawn_command_true_is_not_swallowed() {
let tmp = tempfile::tempdir().unwrap();
let kernel = kernel_at(tmp.path());
let result = kernel.execute("spawn --command true").await.expect("execute");
assert!(
!result.err.contains("a value is required"),
"the literal command should reach spawn: {:?}",
result.err
);
// spawn backgrounds `true` successfully (proves the value reached the
// builtin; a vacuous "command not found: spawn" would be 127).
assert_eq!(result.code, 0, "spawn should succeed: {:?}", result.err);
}
#[tokio::test]
async fn spawn_command_quoted_true_still_works() {
// The pre-existing workaround keeps working — no regression.
let tmp = tempfile::tempdir().unwrap();
let kernel = kernel_at(tmp.path());
let result = kernel
.execute("spawn --command 'true'")
.await
.expect("execute");
assert_ne!(result.code, 2, "quoted form regressed: {:?}", result.err);
}