fix(command): refuse set-axis, set-page and siblings naming what the document lacks (improvise-31oe.2)
set-axis reads its axis at parse time, so an unknown keyword is an argument error. set-axis, set-page, hide-item, show-item, toggle-group and switch-view refuse an unknown category, item, group or view by name instead of doing nothing, so a headless run exits non-zero. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
committed by
Edward Langley
parent
197ce61d65
commit
c40b6d3215
@@ -121,6 +121,58 @@ fn a_parse_error_still_exits_non_zero() {
|
||||
);
|
||||
}
|
||||
|
||||
/// improvise-31oe.2 at the process boundary, with a control that exits 0.
|
||||
/// Evidence: `context/test-evidence/cli.md`.
|
||||
#[test]
|
||||
fn an_unknown_category_axis_or_item_exits_non_zero_and_names_it() {
|
||||
let scratch = Scratch::new("unknown_names");
|
||||
let doc = seeded(&scratch, "m.improv");
|
||||
let out = run_cmd(&["add-item Region East"], &doc);
|
||||
assert!(out.status.success(), "the seed item: {}", stderr_of(&out));
|
||||
for (line, missing) in [
|
||||
("set-axis Regoin row", "Regoin"),
|
||||
("set-page Region Nowhere", "Nowhere"),
|
||||
("set-axis Region sideways", "sideways"),
|
||||
] {
|
||||
let out = run_cmd(&[line], &doc);
|
||||
let said = stderr_of(&out);
|
||||
assert!(!out.status.success(), "`{line}` exited 0; stderr={said:?}");
|
||||
assert!(
|
||||
said.contains(missing),
|
||||
"`{line}` did not name {missing}: {said:?}"
|
||||
);
|
||||
}
|
||||
let out = run_cmd(&["set-page Region East"], &doc);
|
||||
assert!(out.status.success(), "the control: {}", stderr_of(&out));
|
||||
}
|
||||
|
||||
/// improvise-31oe.3: one pipe-quoted argument, and a surplus one refused.
|
||||
/// Evidence: `context/test-evidence/cli.md`.
|
||||
#[test]
|
||||
fn a_pipe_quoted_name_reaches_the_document_whole() {
|
||||
let scratch = Scratch::new("pipes");
|
||||
let doc = seeded(&scratch, "m.improv");
|
||||
let out = run_cmd(&["create-view |By area|"], &doc);
|
||||
assert!(out.status.success(), "{}", stderr_of(&out));
|
||||
let text = std::fs::read_to_string(&doc).expect("the document");
|
||||
assert!(text.contains("## View: By area\n"), "{text}");
|
||||
assert!(
|
||||
!text.contains("|By"),
|
||||
"a pipe reached the view name: {text}"
|
||||
);
|
||||
|
||||
let out = run_cmd(&["create-view By area"], &doc);
|
||||
let said = stderr_of(&out);
|
||||
assert!(
|
||||
!out.status.success(),
|
||||
"a surplus argument exited 0: {said:?}"
|
||||
);
|
||||
assert!(
|
||||
said.contains("\"area\""),
|
||||
"the refusal does not name it: {said:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Diagnostics go to stderr so that stdout stays free for a data output, and
|
||||
/// so `2>/dev/null` is the whole suppression story. `context/code/cli.md`.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user