From 8530c1a64e8f2fe3a1a122322456d41abc41b59f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 15 Nov 2024 21:14:13 +0100 Subject: [PATCH] feat: support hyphen values for --build-jobs (#1874) cargo --jobs supports negative values: https://github.com/rust-lang/cargo/issues/9217 currently this fails: ``` cargo nextest run --build-jobs -1 error: unexpected argument '-1' found tip: to pass '-1' as a value, use '-- -1' ``` because clap doesn't support this by default and requires `allow_hyphen_values = true` https://github.com/clap-rs/clap/issues/1245 --- cargo-nextest/src/cargo_cli.rs | 3 ++- cargo-nextest/src/dispatch.rs | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cargo-nextest/src/cargo_cli.rs b/cargo-nextest/src/cargo_cli.rs index 567fd6eae18..539968cf198 100644 --- a/cargo-nextest/src/cargo_cli.rs +++ b/cargo-nextest/src/cargo_cli.rs @@ -98,7 +98,8 @@ pub(crate) struct CargoOptions { long, value_name = "N", group = "cargo-opts", - help_heading = "Compilation options" + help_heading = "Compilation options", + allow_hyphen_values = true )] build_jobs: Option, diff --git a/cargo-nextest/src/dispatch.rs b/cargo-nextest/src/dispatch.rs index 2ef0e08b1df..f4559212bc1 100644 --- a/cargo-nextest/src/dispatch.rs +++ b/cargo-nextest/src/dispatch.rs @@ -2406,6 +2406,9 @@ mod tests { // Test negative test threads "cargo nextest run --jobs -3", "cargo nextest run --jobs 3", + // Test negative cargo build jobs + "cargo nextest run --build-jobs -1", + "cargo nextest run --build-jobs 1", ]; let invalid: &[(&'static str, ErrorKind)] = &[