summaryrefslogtreecommitdiffstats
path: root/tests/workdir.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/workdir.rs')
-rw-r--r--tests/workdir.rs37
1 files changed, 28 insertions, 9 deletions
diff --git a/tests/workdir.rs b/tests/workdir.rs
index 3c47e948..99f0bf3f 100644
--- a/tests/workdir.rs
+++ b/tests/workdir.rs
@@ -261,18 +261,37 @@ impl WorkDir {
pub fn assert_err(&self, cmd: &mut process::Command) {
let o = cmd.output().unwrap();
if o.status.success() {
- panic!("\n\n===== {:?} =====\n\
- command succeeded but expected failure!\
- \n\ncwd: {}\
- \n\nstatus: {}\
- \n\nstdout: {}\n\nstderr: {}\
- \n\n=====\n",
- cmd, self.dir.display(), o.status,
- String::from_utf8_lossy(&o.stdout),
- String::from_utf8_lossy(&o.stderr));
+ panic!(
+ "\n\n===== {:?} =====\n\
+ command succeeded but expected failure!\
+ \n\ncwd: {}\
+ \n\nstatus: {}\
+ \n\nstdout: {}\n\nstderr: {}\
+ \n\n=====\n",
+ cmd,
+ self.dir.display(),
+ o.status,
+ String::from_utf8_lossy(&o.stdout),
+ String::from_utf8_lossy(&o.stderr)
+ );
}
}
+ /// Runs the given command and asserts that its exit code matches expected exit code.
+ pub fn assert_exit_code(&self, expected_code: i32, cmd: &mut process::Command) {
+ let code = cmd.status().unwrap().code().unwrap();
+
+ assert_eq!(
+ expected_code, code,
+ "\n\n===== {:?} =====\n\
+ expected exit code did not match\
+ \n\nexpected: {}\
+ \n\nfound: {}\
+ \n\n=====\n",
+ cmd, expected_code, code
+ );
+ }
+
/// Runs the given command and asserts that something was printed to
/// stderr.
pub fn assert_non_empty_stderr(&self, cmd: &mut process::Command) {