Skip to content

Commit 326f919

Browse files
committed
fixup arg passing in rpc test_base.py
1 parent fc897f6 commit 326f919

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/rust-cli/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use crate::scenarios::{handle_scenario_command, ScenarioCommand};
1717
#[derive(Parser, Debug)]
1818
#[command(version, about, long_about = None)]
1919
struct Cli {
20-
#[arg(long, default_value = "warnet")]
21-
network: String,
20+
#[arg(long)]
21+
network: Option<String>,
2222

2323
#[command(subcommand)]
2424
command: Option<Commands>,

test/test_base.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import argparse
22
import atexit
33
import os
4+
import shlex
45
import sys
56
import threading
67
from pathlib import Path
@@ -79,14 +80,22 @@ def cleanup(self, signum=None, frame=None):
7980
self.server = None
8081

8182
# Execute a warcli RPC using command line (always returns string)
82-
def warcli(self, str, network=True):
83-
if not self.rust_cli:
84-
print("Not using rust cli")
85-
cmd = ["warcli"] + str.split()
86-
if network:
87-
cmd += ["--network", self.network_name]
83+
def warcli(self, commands, network=True):
84+
cmd = ""
85+
if self.rust_cli:
86+
# a temporary hack to fetch the path of the debug binary
87+
script_path = Path(__file__).resolve()
88+
project_root = script_path.parent.parent
89+
warcli_relative_path = Path("target/debug/warcli")
90+
warcli_absolute_path = project_root / warcli_relative_path
91+
cmd += f"{warcli_absolute_path} "
8892
else:
89-
cmd = ["target/debug/warcli"] + str.split()
93+
cmd += "warcli "
94+
cmd_args = ' '.join(commands.split())
95+
cmd += cmd_args
96+
if network:
97+
cmd += f" --network {self.network_name} "
98+
cmd = shlex.split(cmd)
9099
proc = run(cmd, capture_output=True)
91100

92101
if proc.stderr:

0 commit comments

Comments
 (0)