From b7d00feaddb2817885bc243d4b2a266a4ad04566 Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Thu, 3 Oct 2024 21:05:21 +0200 Subject: [PATCH] Support trailing global flags in the native parser. (#21480) The legacy parser supports having global flags at the end of the command-line invocation, after all specs. Now the native parser supports this too. Fixes #21478 --- src/rust/engine/options/src/args.rs | 3 +++ src/rust/engine/options/src/args_tests.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/rust/engine/options/src/args.rs b/src/rust/engine/options/src/args.rs index 61da16c77f2..0ff58b235b6 100644 --- a/src/rust/engine/options/src/args.rs +++ b/src/rust/engine/options/src/args.rs @@ -127,6 +127,9 @@ impl Args { }); } else if is_valid_scope_name(&arg_str) { scope = Scope::Scope(arg_str) + } else { + // The arg is a spec, so revert to global context for any trailing flags. + scope = Scope::Global; } } diff --git a/src/rust/engine/options/src/args_tests.rs b/src/rust/engine/options/src/args_tests.rs index 939baf5048c..9a96d8bff59 100644 --- a/src/rust/engine/options/src/args_tests.rs +++ b/src/rust/engine/options/src/args_tests.rs @@ -78,6 +78,8 @@ fn test_bool() { "scope", "--no-quuxf", "--quuxt", + "path/to/target", + "--global-flag", ]); let assert_bool = @@ -91,6 +93,7 @@ fn test_bool() { assert_bool(false, option_id!(["scope"], "quxf")); assert_bool(false, option_id!(["scope"], "quuxf")); assert_bool(true, option_id!(["scope"], "quuxt")); + assert_bool(true, option_id!("global", "flag")); assert!(args.get_bool(&option_id!("dne")).unwrap().is_none()); assert!(args.get_passthrough_args().is_none());