Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Dec 23, 2024
1 parent af9df57 commit 60fb6cd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl fmt::Display for CmdError {
}
}
if self.stdout.len() > 0 {
write!(f, "stdout suffix\n{}\n", String::from_utf8_lossy(&self.stdout))?;
write!(f, "stdout suffix:\n{}\n", String::from_utf8_lossy(&self.stdout))?;
}
if self.stderr.len() > 0 {
write!(f, "stderr suffix:\n{}\n", String::from_utf8_lossy(&self.stderr))?;
Expand Down
2 changes: 1 addition & 1 deletion src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub(crate) fn exec(
deadline: Option<Instant>,
) -> ExecResult {
let mut result = ExecResult::default();
command.stdin(if stdin_contents.is_some() { Stdio::inherit() } else { Stdio::null() });
command.stdin(if stdin_contents.is_some() { Stdio::piped() } else { Stdio::null() });
command.stdout(Stdio::piped());
command.stderr(Stdio::piped());
let mut child = match command.spawn() {
Expand Down
21 changes: 18 additions & 3 deletions tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,17 @@ fn exit_status() {
let sh = setup();

let err = cmd!(sh, "xecho -f").read().unwrap_err();
assert_eq!(err.to_string(), "command exited with non-zero code `xecho -f`: 1");
assert_eq!(
err.to_string(),
r#"command exited with non-zero code `xecho -f`: 1
stdout suffix:
stderr suffix:
other error
"#
);
}

#[test]
Expand All @@ -150,7 +160,11 @@ fn exit_status_signal() {
let sh = setup();

let err = cmd!(sh, "xecho -s").read().unwrap_err();
assert_eq!(err.to_string(), "command was terminated by a signal `xecho -s`: 9");
assert_eq!(err.to_string(), r#"command was terminated by a signal `xecho -s`: 9
stdout suffix:
"#);
}

#[test]
Expand Down Expand Up @@ -226,7 +240,8 @@ bar
"\
foo
baz
bar"
bar
"
)
}

Expand Down

0 comments on commit 60fb6cd

Please sign in to comment.