This repository was archived by the owner on Dec 29, 2021. It is now read-only.
This repository was archived by the owner on Dec 29, 2021. It is now read-only.
Deprecate macro in favor of clever Assert::command(&str)
? #25
Open
Description
What do you think about removing the macro and adding <T: ToCommandWithArgs> Assert::command(T)
where ToCommandWithArgs
is a trait implemented for &[u8]
as well as &str
? This way, you could run Assert::command(r#"cargo run --bin whatever -- --input="Lorem ipsum" -f"#)
.
In the &str
case we'd parse it in a clever way to split the string by whitespace while preserving quoted blocks. I'm thinking of some split_args
that fulfills
#[test]
fn test_arg_split() {
assert_eq(split_args("echo 42"), vec!["echo", "42"]);
assert_eq(split_args(r#"echo "42""#), vec!["echo", "\"42\""]);
assert_eq(
split_args(r#"cargo run --bin whatever -- --input="Lorem ipsum" -f"#),
vec!["cargo", "run", "--bin", "whatever", "--", "--input=\"Lorem ipsum\"", "-f"]
);
}
(Copypasta from #22 (comment))