mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
tty: Make test_stdout_fail() less flaky
This commit is contained in:
parent
91d39de16e
commit
8f901ee860
1 changed files with 17 additions and 4 deletions
|
@ -66,10 +66,23 @@ fn test_wrong_argument() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
// FixME: freebsd panic
|
// FixME: freebsd panic
|
||||||
#[cfg(not(any(windows, target_os = "freebsd")))]
|
#[cfg(all(unix, not(target_os = "freebsd")))]
|
||||||
fn test_stdout_fail() {
|
fn test_stdout_fail() {
|
||||||
let mut child = new_ucmd!().run_no_wait();
|
use std::process::{Command, Stdio};
|
||||||
drop(child.stdout.take());
|
let ts = TestScenario::new(util_name!());
|
||||||
let status = child.wait().unwrap();
|
// Sleep inside a shell to ensure the process doesn't finish before we've
|
||||||
|
// closed its stdout
|
||||||
|
let mut proc = Command::new("sh")
|
||||||
|
.arg("-c")
|
||||||
|
.arg(format!(
|
||||||
|
"sleep 0.2; exec {} {}",
|
||||||
|
ts.bin_path.to_str().unwrap(),
|
||||||
|
ts.util_name
|
||||||
|
))
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
drop(proc.stdout.take());
|
||||||
|
let status = proc.wait().unwrap();
|
||||||
assert_eq!(status.code(), Some(3));
|
assert_eq!(status.code(), Some(3));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue