use super::*;
pub(crate) trait ToArgs {
fn to_args(&self) -> Vec<String>;
}
impl ToArgs for String {
fn to_args(&self) -> Vec<String> {
self.as_str().to_args()
}
}
impl ToArgs for &str {
fn to_args(&self) -> Vec<String> {
self.split_whitespace().map(str::to_string).collect()
}
}
impl<const N: usize> ToArgs for [&str; N] {
fn to_args(&self) -> Vec<String> {
self.iter().cloned().map(str::to_string).collect()
}
}
impl ToArgs for Vec<String> {
fn to_args(&self) -> Vec<String> {
self.clone()
}
}
pub(crate) struct CommandBuilder {
args: Vec<String>,
expected_exit_code: i32,
expected_stderr: Expected,
expected_stdout: Expected,
rpc_server_url: Option<String>,
stdin: Vec<u8>,
tempdir: TempDir,
}
impl CommandBuilder {
pub(crate) fn new(args: impl ToArgs) -> Self {
Self {
args: args.to_args(),
expected_exit_code: 0,
expected_stderr: Expected::String(String::new()),
expected_stdout: Expected::String(String::new()),
rpc_server_url: None,