#[cfg(feature = "mcp")]
#[test]
fn test_mcp_help_output() {
let build = std::process::Command::new("cargo")
.args(["build", "--bin", "ts-pack", "--features", "mcp"])
.status()
.expect("failed to run cargo build");
assert!(build.success(), "cargo build with mcp feature should succeed");
let binary = env!("CARGO_TARGET_TMPDIR")
.split("target")
.next()
.map(|prefix| format!("{prefix}target/debug/ts-pack"))
.unwrap_or_else(|| "target/debug/ts-pack".to_string());
let output = std::process::Command::new(&binary)
.args(["mcp", "--help"])
.output()
.expect("failed to run ts-pack mcp --help");
assert!(output.status.success(), "mcp --help should exit with status 0");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
stdout.contains("MCP") || stdout.contains("Model Context Protocol"),
"help text should mention MCP"
);
assert!(stdout.contains("--transport"), "help text should list --transport flag");
assert!(stdout.contains("--port"), "help text should list --port flag");
assert!(stdout.contains("--config"), "help text should list --config flag");
}
#[cfg(not(feature = "mcp"))]
#[test]
fn test_mcp_subcommand_absent_without_feature() {
let output = std::process::Command::new("cargo")
.args(["run", "--bin", "ts-pack", "--", "mcp", "--help"])
.output()
.expect("failed to run ts-pack");
assert!(
!output.status.success(),
"ts-pack mcp should be unknown without the mcp feature"
);
}