Skip to content
Merged
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
31 changes: 31 additions & 0 deletions pkgs/fleet/crates/fleet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,16 @@ fn run_domain(surface: &Surface, d: &Domain, args: &[String], invoked_as: &str)
args.first().map(|s| s.as_str()),
Some("--version") | Some("-V")
) {
// The version shortcut takes no trailing arguments:
// like the root built-ins (#5572), a trailing argument
// is a usage error naming it, not silently discarded
// success (#5603).
if let Some(extra) = args.get(1) {
return usage_error(&format!(
"unexpected argument '{extra}' for 'fleet queue {}'",
args.first().map(|s| s.as_str()).unwrap_or("--version")
));
}
println!(
"{} {VERSION}",
if invoked_as == "repo-queue" {
Expand Down Expand Up @@ -831,4 +841,25 @@ mod tests {
);
}
}

#[test]
fn queue_domain_version_rejects_trailing_arguments() {
Comment on lines +845 to +846

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate the queue-specific test on the queue feature

For the supported serve and connect feature sets, which do not enable queue, this unconditional test fails: Surface::new excludes Capability::Queue, so run_domain correctly takes the capability-stub path and returns EXIT_UNAVAILABLE (69), rather than the asserted EXIT_USAGE (2). The bare-version assertion also expects success despite that capability being unavailable. Gate this test with #[cfg(feature = "queue")] or assert the appropriate stub behavior when the feature is disabled.

Useful? React with 👍 / 👎.

// #5603: the queue domain's --version shortcut in run_domain
// checked only the first argument, so `fleet queue --version
// --bogus` (and the repo-queue argv0 form) returned success.
let surface = Surface::new(None, fleet_config::Config::default());
let queue = domain("queue").expect("queue domain exists");
for flag in ["--version", "-V"] {
assert_eq!(
run_domain(&surface, queue, &args(&[flag, "--bogus"]), "fleet"),
EXIT_USAGE,
"{flag} must reject a trailing argument"
);
assert_eq!(
run_domain(&surface, queue, &args(&[flag]), "fleet"),
EXIT_OK,
"bare {flag} stays accepted"
);
}
}
}