From f3b3fc23d23c65d98854fce4b2ab0064763c03eb Mon Sep 17 00:00:00 2001 From: Dylan Frankland Date: Mon, 9 Dec 2024 11:30:06 -0800 Subject: [PATCH] fix setting default-true flags to false --- cli-tests/src/upload.rs | 11 ++++++++++- cli/src/upload.rs | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cli-tests/src/upload.rs b/cli-tests/src/upload.rs index 52dfb73c..5d18ae6f 100644 --- a/cli-tests/src/upload.rs +++ b/cli-tests/src/upload.rs @@ -324,6 +324,8 @@ async fn upload_bundle_no_files_allow_missing_junit_files() { } }; + args.push("--print-files"); + let mut assert = Command::new(CARGO_RUN.path()) .current_dir(&temp_dir) .env("TRUNK_PUBLIC_API_ADDRESS", &state.host) @@ -340,7 +342,14 @@ async fn upload_bundle_no_files_allow_missing_junit_files() { assert.success() }; - assert = assert.stderr(predicate::str::contains("unexpected argument").not()); + let predicate_fn = predicate::str::contains("unexpected argument"); + + // `=` is required to set the flag to `false` + assert = if matches!(flag, Flag::Off | Flag::OffAlias) { + assert.stderr(predicate_fn) + } else { + assert.stderr(predicate_fn.not()) + }; // HINT: View CLI output with `cargo test -- --nocapture` println!("{assert}"); diff --git a/cli/src/upload.rs b/cli/src/upload.rs index 70909251..58d556f0 100644 --- a/cli/src/upload.rs +++ b/cli/src/upload.rs @@ -88,6 +88,7 @@ pub struct UploadArgs { help = "Run commands with the quarantining step.", action = ArgAction::Set, required = false, + require_equals = true, num_args = 0..=1, default_value = "true", default_missing_value = "true", @@ -99,6 +100,7 @@ pub struct UploadArgs { help = "Do not fail if test results are not found.", action = ArgAction::Set, required = false, + require_equals = true, num_args = 0..=1, default_value = "true", default_missing_value = "true",