extern crate subprocess;
use std::io::Read;
use std::path::Path;
use subprocess::{Exec, Redirection};
fn just_echo_path() -> String {
let prog = Path::new(&::std::env::args().next().unwrap()).to_owned();
let prog = prog.parent().unwrap(); let prog = prog.parent().unwrap(); prog.join("just-echo").to_str().unwrap().to_owned()
}
#[test]
fn weird_args() {
for &arg in [
"x", "", " ", " ", r" \ ", r" \\ ", r" \\\ ", r#"""#, r#""""#, r#"\"\\""#,
]
.iter()
{
println!("running {:?} {:?}", arg, just_echo_path());
let mut handle = Exec::cmd(just_echo_path())
.arg(arg)
.stdout(Redirection::Pipe)
.start()
.unwrap();
let mut output = handle.stdout.take().unwrap();
let mut output_str = String::new();
output.read_to_string(&mut output_str).unwrap();
assert_eq!(output_str, arg);
}
}