Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

test(host): a test host that doesn't start says why

leepokaibd1942b18a1e
diff --git a/host/tests/common/mod.rs b/host/tests/common/mod.rs
index eb4009fb..f6b604bd 100644
--- a/host/tests/common/mod.rs
+++ b/host/tests/common/mod.rs
@@ -11,6 +11,9 @@ use std::time::{Duration, Instant};
/// host exits and this starts it again on another one.
pub async fn serve(home: &Path) -> (Child, String) {
let deadline = Instant::now() + Duration::from_secs(30);
+ let _ = std::fs::create_dir_all(home);
+ let log = home.join("host-stderr.log");
+ let mut last = String::new();
loop {
let port = std::net::TcpListener::bind("127.0.0.1:0").expect("free port").local_addr().expect("port").port();
let base = format!("http://127.0.0.1:{port}");
@@ -19,20 +22,29 @@ pub async fn serve(home: &Path) -> (Child, String) {
.env("CODYNC_HOME", home)
.env("CODYNC_CLOUD", "off")
.stdout(Stdio::null())
- .stderr(Stdio::null())
+ .stderr(std::fs::File::create(&log).map_or_else(|_| Stdio::null(), Stdio::from))
.spawn()
.expect("start the host");
while child.try_wait().expect("host state").is_none() {
- if reqwest::get(format!("{base}/health")).await.is_ok() {
- return (child, base);
+ match reqwest::get(format!("{base}/health")).await {
+ Ok(_) => return (child, base),
+ Err(e) => last = format!("{e:?}"),
}
- assert!(Instant::now() < deadline, "host didn't start");
+ assert!(Instant::now() < deadline, "{}", not_started(&log, &last));
tokio::time::sleep(Duration::from_millis(50)).await;
}
- assert!(Instant::now() < deadline, "host didn't start");
+ assert!(Instant::now() < deadline, "{}", not_started(&log, &last));
}
}
+/// Why a test host didn't answer: the last health check's error and the end of the host's log.
+fn not_started(log: &Path, last: &str) -> String {
+ let text = std::fs::read_to_string(log).unwrap_or_default();
+ let lines: Vec<&str> = text.lines().collect();
+ let tail = lines[lines.len().saturating_sub(30)..].join("\n");
+ format!("host didn't start; last health check: {last}\n--- host log ---\n{tail}")
+}
+
/// Stops a test host the way launchd does (SIGTERM), so it shuts down its own
/// children: a SIGKILL would orphan whatever it had running, such as a harness
/// sign-in check (`cursor-agent status` then spins forever). Kills it after 5 s.