From 20aaabfd9c68796e56a2b870723abd333206d8df Mon Sep 17 00:00:00 2001 From: Liu Yuxi Date: Sat, 9 Nov 2024 20:03:14 +0000 Subject: [PATCH] fix(xtask): remove the `test_flags` arg if it's empty for cargo test `cargo xtask test test_something` currently constructs `cargo test '' test_something`, which errors out for `cargo test`. This fix removes the `test_flags` string if it's empty. --- xtask/src/test.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xtask/src/test.rs b/xtask/src/test.rs index fd09bd94..660c30e5 100644 --- a/xtask/src/test.rs +++ b/xtask/src/test.rs @@ -86,7 +86,11 @@ pub fn run(args: &Test) -> Result<()> { )?; } else { let mut cargo_cmd = Command::new("cargo"); - cargo_cmd.arg("test").arg(test_flags).args(&args.args); + cargo_cmd.arg("test"); + if !test_flags.is_empty() { + cargo_cmd.arg(test_flags); + } + cargo_cmd.args(&args.args); if args.nocapture { cargo_cmd.arg("--").arg("--nocapture"); }