From 9204e472e4f714c84237bca5ebe740080a589917 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Wed, 8 Oct 2025 11:58:49 +0200 Subject: test(crates/rocie-server/testenv/init): Automatically choose the port and wait for server start This avoids issues regarding a race condition between server start and our start of requests and removes the requirement for specifying free ports in the test files. --- crates/rocie-server/src/cli.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'crates/rocie-server/src/cli.rs') diff --git a/crates/rocie-server/src/cli.rs b/crates/rocie-server/src/cli.rs index b2ec214..80b4292 100644 --- a/crates/rocie-server/src/cli.rs +++ b/crates/rocie-server/src/cli.rs @@ -13,8 +13,16 @@ pub(crate) enum Command { /// Serve the server. Serve { /// Which port to serve the server on. - #[arg(short, long, default_value = "8080")] - port: u16, + /// + /// Leave empty to let the OS choose a free one. + #[arg(short, long)] + port: Option, + + /// Print the used port as single u16 to stdout when started. + /// + /// This can be used, to determine the used port, when the `port` was left at `None`. + #[arg(long)] + print_port: bool, /// Which host to serve the server on. #[arg(short = 'b', long, default_value = "127.0.0.1")] -- cgit 1.4.1