From 507dca786f03c7b3b3feb4216fcd96e117b7f16e Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sun, 22 Nov 2026 23:35:58 +0700 Subject: [PATCH] Control port errors in the start-up test read the framework's wording; port 0 picks a free port --- apps/vectorcraft/tests/it/automation_args.rs | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/apps/vectorcraft/tests/it/automation_args.rs b/apps/vectorcraft/tests/it/automation_args.rs index 4a1e6f524c..4d33caaa82 100644 --- a/apps/vectorcraft/tests/it/automation_args.rs +++ b/apps/vectorcraft/tests/it/automation_args.rs @@ -79,17 +79,20 @@ fn explicit_dash_folder_does_not_consume_version() { } /// `--control` without a port no longer starts the app without a control server, and the -/// argument after it isn't reinterpreted (#1373). +/// argument after it isn't reinterpreted (#1373). The port's wording and range are the framework's +/// (`control_port`; port 0 picks a free port). #[test] fn control_without_a_valid_port_fails_before_startup() { - let need = "--control needs a port number from 1 to 65535"; - rejects(&["--control", "--automation-read-root", ".", "--automation-write-root", "."], &format!("{need}, not `--automation-read-root`")); - rejects(&["--control"], need); - rejects(&["--control", "abc"], &format!("{need}, not `abc`")); - rejects(&["--control=0"], &format!("{need}, not `0`")); - rejects(&["--control="], &format!("{need}, not ``")); - rejects(&["--control", "7979", "--control", "7980"], "--control given twice"); - rejects_with_env(&[], &[("VECTORCRAFT_CONTROL_PORT", "abc")], "VECTORCRAFT_CONTROL_PORT needs a port number from 1 to 65535, not `abc`"); + use craft::automation::args::OptionsError; + let not_a_port = |value: &str, shown: &str| OptionsError::NotAPort { value: value.into(), shown: shown.into() }.to_string(); + let flag = "--control "; + rejects(&["--control", "--automation-read-root", ".", "--automation-write-root", "."], ¬_a_port("--automation-read-root", flag)); + rejects(&["--control"], "a value is required for '--control' but none was supplied"); + rejects(&["--control", "abc"], ¬_a_port("abc", flag)); + rejects(&["--control=65536"], ¬_a_port("65536", flag)); + rejects(&["--control="], ¬_a_port("", flag)); + rejects(&["--control", "7979", "--control", "7980"], "the argument '--control' cannot be used multiple times"); + rejects_with_env(&[], &[("VECTORCRAFT_CONTROL_PORT", "abc")], ¬_a_port("abc", "VECTORCRAFT_CONTROL_PORT")); } #[test]