Reorder test arguments to handle user-provided args
Pass test arguments to `cargo test` after the `--manifest-path`
argument. Otherwise, if the user passes args of the form `-- --other`,
the --manifest-path gets ignored by `cargo test`.
Test: fargo test --app-name wlancfg_lib_lib_test --sandbox-file-path \
meta/wlancfg_lib_lib_test.cml --manifest-path \
src/connectivity/wlan/wlancfg/Cargo.toml -- -- -- --test-filter \
'*network_selection*'
Change-Id: I78faf937cf5fd0e20bdd27aa68c6ac70c60d93f6
Reviewed-on: https://fuchsia-review.googlesource.com/c/fargo/+/564011
Reviewed-by: Rob Tsuk <robtsuk@google.com>
diff --git a/src/lib.rs b/src/lib.rs
index 6695f26..199e902 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -651,8 +651,7 @@
.env("RUSTDOCFLAGS", &rustflags)
.env("FUCHSIA_SHARED_ROOT", shared_libraries_path(target_options)?)
.arg(subcommand)
- .args(target_args)
- .args(args);
+ .args(target_args);
if let Some(ref manifest_path) = options.manifest_path {
let manifest_args: Vec<&str> = vec![
@@ -662,6 +661,9 @@
cmd.args(manifest_args);
}
+ // Pass `args` last so any trailing args using `--` don't cause our other args to be ignored
+ cmd.args(args);
+
if !options.disable_cross {
let cc_env_name = format!("CC_{}", target_triple_uc);
let cxx_env_name = format!("CXX_{}", target_triple_uc);