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.
This commit is contained in:
Liu Yuxi 2024-11-09 20:03:14 +00:00 committed by GitHub
parent 0f15779863
commit 20aaabfd9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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");
}