ソースを参照

cli: Add support for multiple commands with `anchor test` (#2799)

Aoi Kurokawa 1 年間 前
コミット
94fde24339
2 ファイル変更5 行追加8 行削除
  1. 1 0
      CHANGELOG.md
  2. 4 8
      cli/src/lib.rs

+ 1 - 0
CHANGELOG.md

@@ -22,6 +22,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 - ts: Add IdlSeed Type for IDL PDA seeds ([#2752](https://github.com/coral-xyz/anchor/pull/2752)).
 - cli: `idl close` accepts optional `--idl-address` parameter ([#2760](https://github.com/coral-xyz/anchor/pull/2760)).
 - cli: Add support for simple wildcard patterns in Anchor.toml's `workspace.members` and `workspace.exclude`. ([#2785](https://github.com/coral-xyz/anchor/pull/2785)).
+- cli: `anchor test` is able to run multiple commands ([#2799](https://github.com/coral-xyz/anchor/pull/2799)).
 
 ### Fixes
 

+ 4 - 8
cli/src/lib.rs

@@ -3201,14 +3201,10 @@ fn run_test_suite(
             .get("test")
             .expect("Not able to find script for `test`")
             .clone();
-        let mut args: Vec<&str> = cmd
-            .split(' ')
-            .chain(extra_args.iter().map(|arg| arg.as_str()))
-            .collect();
-        let program = args.remove(0);
-
-        std::process::Command::new(program)
-            .args(args)
+        let script_args = format!("{cmd} {}", extra_args.join(" "));
+        std::process::Command::new("bash")
+            .arg("-c")
+            .arg(script_args)
             .env("ANCHOR_PROVIDER_URL", url)
             .env("ANCHOR_WALLET", cfg.provider.wallet.to_string())
             .env("NODE_OPTIONS", node_options)