review: loopd prints every startup notice before it binds; tests wait for "serving on"

The serve tests waited for the socket file, then killed `loopd` and read its stderr, but the
socket is bound before its mode is set and before "serving on" and the broker notice are printed,
so a kill in between lost those lines (`pointers` failed once under load in M5c-1 task 15). The
broker notice now comes before the bind, so "serving on" is the last startup line, and the tests
wait for it (`tests/support/serving.rs`).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-28 14:26:37 -07:00
co-authored by Claude Opus 5.5
parent 45be83b891
commit e83b53b8b6
4 changed files with 89 additions and 42 deletions
+8 -18
View File
@@ -2,6 +2,8 @@
//! `scripts/check-runbook.sh` checks that the entries exist; these tests check that the messages
//! name them. Do not edit.
#[path = "support/serving.rs"]
mod serving;
mod support;
use std::path::Path;
@@ -162,20 +164,10 @@ fn healthy_routes(server: &FakeServer) {
);
}
/// Waits for `loopd serve` to bind its socket, stops it, and returns what it printed.
fn stderr_once_serving(mut child: Child, socket: &Path) -> String {
let mut up = false;
for _ in 0..200 {
if socket.exists() {
up = true;
break;
}
std::thread::sleep(Duration::from_millis(50));
}
child.kill().unwrap();
let output = child.wait_with_output().unwrap();
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
assert!(up, "the socket never appeared; stderr: {stderr}");
/// Waits for `loopd serve` to print "serving on", stops it, and returns what it printed.
fn stderr_once_serving(child: Child) -> String {
let (up, stderr) = serving::stderr_once_serving(child);
assert!(up, "loopd never said it was serving; stderr: {stderr}");
stderr
}
@@ -218,8 +210,7 @@ fn serve_without_a_broker_says_so_once_with_the_entry() {
let server = FakeServer::start();
healthy_routes(&server);
let config = config_file(&home, &server, 2, "");
let socket = home.dir.join("run/loop/loop.sock");
let stderr = stderr_once_serving(serve(&config), &socket);
let stderr = stderr_once_serving(serve(&config));
let lines: Vec<&str> = stderr
.lines()
.filter(|l| l.contains("no tool broker is configured"))
@@ -240,8 +231,7 @@ fn serve_with_a_broker_socket_does_not_say_it() {
home.dir.join("run/loop-broker/broker.sock").display()
);
let config = config_file(&home, &server, 2, &extra);
let socket = home.dir.join("run/loop/loop.sock");
let stderr = stderr_once_serving(serve(&config), &socket);
let stderr = stderr_once_serving(serve(&config));
assert!(!stderr.contains("no tool broker"), "{stderr}");
assert!(stderr.contains("serving on"), "{stderr}");
}