Skip to content

Commit

Permalink
test: mock: Add expect_ok_eq function
Browse files Browse the repository at this point in the history
Compares two different command invocations and panics if their return
code and stdout/stderr don't match.
  • Loading branch information
yodaldevoid committed Mar 30, 2019
1 parent 8a189fa commit 9bb56d0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/mock/clitools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ pub fn expect_ok_contains(config: &Config, args: &[&str], stdout: &str, stderr:
}
}

pub fn expect_ok_eq(config: &Config, args1: &[&str], args2: &[&str]) {
let out1 = run(config, args1[0], &args1[1..], &[]);
let out2 = run(config, args2[0], &args2[1..], &[]);
if !out1.ok || !out2.ok || out1.stdout != out2.stdout || out1.stderr != out2.stderr {
print_command(args1, &out1);
println!("expected.ok: {}", true);
print_command(args2, &out2);
println!("expected.ok: {}", true);
panic!();
}
}

fn print_command(args: &[&str], out: &SanitizedOutput) {
print!("\n>");
for arg in args {
Expand Down

0 comments on commit 9bb56d0

Please sign in to comment.