Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions apps/origin-src/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand All @@ -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)
}

Expand Down
Loading