Skip to content

Commit

Permalink
Fix test using stderr with Docker --tty (memorysafety#622)
Browse files Browse the repository at this point in the history
Docker merges stderr into stdout when `--tty` is set [1].

This was the only test I found with this case.

[1]: moby/moby#25542
  • Loading branch information
xy2i committed Aug 13, 2023
1 parent a0fe3fc commit 857b1c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions commmit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[1]: https://github.com/moby/moby/issues/25542
16 changes: 9 additions & 7 deletions test-framework/sudo-compliance-tests/src/sudo/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,21 @@ fn closes_open_file_descriptors(tty: bool) -> Result<()> {
assert!(!output.status().success());
assert_eq!(Some(1), output.status().code());

assert_contains!(output.stderr(), "42: Bad file descriptor");
assert_contains!(
if tty {
// Docker merges stderr into stdout with "--tty". See gh622
output.stdout_unchecked()
} else {
output.stderr()
},
"42: Bad file descriptor"
);

Ok(())
}

#[test]
#[ignore = "gh622"]
fn closes_open_file_descriptors_with_tty() -> Result<()> {
// FIXME: not clear why ogsudo can't deal with this either
if sudo_test::is_original_sudo() {
return Ok(());
}

closes_open_file_descriptors(true)
}

Expand Down

0 comments on commit 857b1c1

Please sign in to comment.