use std::process::Command; macro_rules! cli_test { ($name:ident, $args:expr, $expected_out:expr) => { #[test] fn $name() { let mut split = $args.split(" "); let command = split.next().unwrap(); let mut rest: Vec<&str> = split.collect(); let mut args = vec!["run", "--bin", command, "--"]; args.append(&mut rest); println!("args: cargo {:?}", args); let output = Command::new("cargo").args(&args).output().unwrap(); assert!(output.status.success()); assert_eq!(String::from_utf8_lossy(&output.stdout), $expected_out); } }; } cli_test!( task_add_help, "task add --help", "Usage: task-add [options] [