Skip to content

Commit f82e3e5

Browse files
test: keep one end-to-end CLI help spawn
Renames the in-process render check to say what it actually covers and adds a single binary invocation asserting the CLI prints exactly the rendered help, so tool-name resolution and help dispatch stay covered end-to-end. Also uses strip_prefix for the short-name helper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent dac12dc commit f82e3e5

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/mcp/tools/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub fn render_tool_cli_help(def: &ToolDefinition) -> String {
161161
}
162162

163163
fn short_tool_name(full: &str) -> &str {
164-
full.trim_start_matches("tracedecay_")
164+
full.strip_prefix("tracedecay_").unwrap_or(full)
165165
}
166166

167167
#[cfg(test)]

tests/agent_suite/tool_skill_coverage_test.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn every_mcp_tool_is_listed_by_the_cli_discovery_command() {
4747
}
4848

4949
#[test]
50-
fn every_mcp_tool_is_invocable_via_the_cli() {
50+
fn every_mcp_tool_renders_its_own_cli_help() {
5151
for def in get_tool_definitions() {
5252
let short = short_name(&def.name);
5353
let stdout = render_tool_cli_help(&def);
@@ -58,6 +58,35 @@ fn every_mcp_tool_is_invocable_via_the_cli() {
5858
}
5959
}
6060

61+
/// One real `tracedecay tool <name> --help` invocation, asserting the binary
62+
/// prints exactly what `render_tool_cli_help` renders. Tool-name resolution
63+
/// and help dispatch are shared across tools, so a single spawn keeps the CLI
64+
/// wiring covered end-to-end without paying one process per tool.
65+
#[test]
66+
fn tool_cli_help_matches_rendered_help_end_to_end() {
67+
let home = TempDir::new().expect("create isolated TraceDecay home");
68+
let def = get_tool_definitions()
69+
.into_iter()
70+
.next()
71+
.expect("at least one MCP tool definition");
72+
let short = short_name(&def.name);
73+
let output = isolated_tracedecay_command(&home)
74+
.args(["tool", short, "--help"])
75+
.output()
76+
.unwrap_or_else(|e| panic!("run `tracedecay tool {short} --help`: {e}"));
77+
assert!(
78+
output.status.success(),
79+
"`tracedecay tool {short} --help` must succeed so tools stay invocable \
80+
without an MCP client:\n{}",
81+
String::from_utf8_lossy(&output.stderr)
82+
);
83+
assert_eq!(
84+
String::from_utf8_lossy(&output.stdout),
85+
render_tool_cli_help(&def),
86+
"CLI help output should be exactly the rendered help"
87+
);
88+
}
89+
6190
/// True when `haystack` mentions `tool_name` as a standalone identifier
6291
/// (not as a prefix of a longer tool name such as `tracedecay_lcm_expand`
6392
/// inside `tracedecay_lcm_expand_query`).

0 commit comments

Comments
 (0)