From ca7bcb053490062d926690ca79582f14a4623a9b Mon Sep 17 00:00:00 2001 From: piquel Date: Sun, 22 Nov 2026 20:27:55 +0100 Subject: [PATCH] test(common): kill the test server when it prints no address `Server::serve` unwrapped the first line of `origin serve` before anything owned the child, so a server that failed to start, or printed something else, was left running, unreaped, when the test panicked. Now the child is killed and waited for before the panic, which says what the server printed. --- apps/origin-src/tests/common/mod.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/origin-src/tests/common/mod.rs b/apps/origin-src/tests/common/mod.rs index f93ef5cd..3fec8b2b 100644 --- a/apps/origin-src/tests/common/mod.rs +++ b/apps/origin-src/tests/common/mod.rs @@ -398,7 +398,7 @@ impl Server { } /// Runs `origin serve` with `config`, returning it and its base URL - /// once it listens. + /// once it listens. Kills it if it says nothing else first. fn serve(config: &Path) -> (Child, String) { let mut child = Command::new(origin()) .args(["serve", "--config"]) @@ -408,14 +408,13 @@ impl Server { .spawn() .unwrap(); let mut line = String::new(); - BufReader::new(child.stdout.take().unwrap()) - .read_line(&mut line) - .unwrap(); - let base = line - .trim() - .strip_prefix("Listening on ") - .unwrap() - .to_owned(); + let read = BufReader::new(child.stdout.take().unwrap()).read_line(&mut line); + let Some(base) = line.trim().strip_prefix("Listening on ") else { + let _ = child.kill(); + let _ = child.wait(); + panic!("`origin serve` printed {line:?} ({read:?}), not its address"); + }; + let base = base.to_owned(); (child, base) }