Skip to content

Commit ae179b4

Browse files
committed
Improve mcp test coverage in workspace
Use the workspace-built MCP binary directly in tests so regressions are caught without requiring a live server and without recompiling from inside each test. Generated with the assistance of AI (Claude).
1 parent 1b48e36 commit ae179b4

1 file changed

Lines changed: 4 additions & 29 deletions

File tree

ldk-server-mcp/tests/integration.rs

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// licenses.
99

1010
use std::io::{BufRead, BufReader, Write};
11-
use std::process::{Command, Stdio};
1211

1312
use serde_json::{json, Value};
1413

@@ -61,29 +60,6 @@ fn test_cert_path() -> String {
6160
.to_string()
6261
}
6362

64-
fn cargo_bin_path() -> String {
65-
let output = Command::new("cargo")
66-
.args(["build", "--message-format=json"])
67-
.stderr(Stdio::piped())
68-
.stdout(Stdio::piped())
69-
.output()
70-
.expect("Failed to build binary");
71-
72-
let stdout = String::from_utf8(output.stdout).unwrap();
73-
for line in stdout.lines() {
74-
if let Ok(msg) = serde_json::from_str::<Value>(line) {
75-
if msg.get("reason").and_then(|r| r.as_str()) == Some("compiler-artifact")
76-
&& msg.get("target").and_then(|t| t.get("name")).and_then(|n| n.as_str())
77-
== Some("ldk-server-mcp")
78-
&& msg.get("executable").and_then(|e| e.as_str()).is_some()
79-
{
80-
return msg["executable"].as_str().unwrap().to_string();
81-
}
82-
}
83-
}
84-
panic!("Could not find compiled binary path");
85-
}
86-
8763
struct McpProcess {
8864
child: std::process::Child,
8965
stdin: std::process::ChildStdin,
@@ -92,14 +68,13 @@ struct McpProcess {
9268

9369
impl McpProcess {
9470
fn spawn() -> Self {
95-
let bin = cargo_bin_path();
96-
let mut child = Command::new(&bin)
71+
let mut child = std::process::Command::new(env!("CARGO_BIN_EXE_ldk-server-mcp"))
9772
.env("LDK_BASE_URL", "localhost:19999")
9873
.env("LDK_API_KEY", "deadbeef")
9974
.env("LDK_TLS_CERT_PATH", test_cert_path())
100-
.stdin(Stdio::piped())
101-
.stdout(Stdio::piped())
102-
.stderr(Stdio::piped())
75+
.stdin(std::process::Stdio::piped())
76+
.stdout(std::process::Stdio::piped())
77+
.stderr(std::process::Stdio::piped())
10378
.spawn()
10479
.expect("Failed to spawn MCP process");
10580

0 commit comments

Comments
 (0)