mirror of
https://github.com/uutils/coreutils
synced 2024-09-06 16:03:44 +00:00
tests/util: Use Stdio::null as default in UCommand for Child stdin instead of Stdio::piped
This commit is contained in:
parent
c2e4da97da
commit
9b35c5d5c1
|
@ -1,3 +1,5 @@
|
|||
use std::process::Stdio;
|
||||
|
||||
use crate::common::util::*;
|
||||
|
||||
#[test]
|
||||
|
@ -373,7 +375,12 @@ fn test_rm_descend_directory() {
|
|||
at.touch(file_1);
|
||||
at.touch(file_2);
|
||||
|
||||
let mut child = scene.ucmd().arg("-ri").arg("a").run_no_wait();
|
||||
let mut child = scene
|
||||
.ucmd()
|
||||
.set_stdin(Stdio::piped())
|
||||
.arg("-ri")
|
||||
.arg("a")
|
||||
.run_no_wait();
|
||||
child.try_write_in(yes.as_bytes()).unwrap();
|
||||
child.try_write_in(yes.as_bytes()).unwrap();
|
||||
child.try_write_in(yes.as_bytes()).unwrap();
|
||||
|
@ -445,7 +452,12 @@ fn test_rm_prompts() {
|
|||
.arg(file_2)
|
||||
.succeeds();
|
||||
|
||||
let mut child = scene.ucmd().arg("-ri").arg("a").run_no_wait();
|
||||
let mut child = scene
|
||||
.ucmd()
|
||||
.set_stdin(Stdio::piped())
|
||||
.arg("-ri")
|
||||
.arg("a")
|
||||
.run_no_wait();
|
||||
for _ in 0..9 {
|
||||
child.try_write_in(yes.as_bytes()).unwrap();
|
||||
}
|
||||
|
@ -486,7 +498,12 @@ fn test_rm_force_prompts_order() {
|
|||
at.touch(empty_file);
|
||||
|
||||
// This should cause rm to prompt to remove regular empty file
|
||||
let mut child = scene.ucmd().arg("-fi").arg(empty_file).run_no_wait();
|
||||
let mut child = scene
|
||||
.ucmd()
|
||||
.set_stdin(Stdio::piped())
|
||||
.arg("-fi")
|
||||
.arg(empty_file)
|
||||
.run_no_wait();
|
||||
child.try_write_in(yes.as_bytes()).unwrap();
|
||||
|
||||
let result = child.wait().unwrap();
|
||||
|
|
|
@ -351,7 +351,11 @@ fn test_follow_stdin_descriptor() {
|
|||
|
||||
let mut args = vec!["-f", "-"];
|
||||
for _ in 0..2 {
|
||||
let mut p = ts.ucmd().args(&args).run_no_wait();
|
||||
let mut p = ts
|
||||
.ucmd()
|
||||
.set_stdin(Stdio::piped())
|
||||
.args(&args)
|
||||
.run_no_wait();
|
||||
p.make_assertion_with_delay(500).is_alive();
|
||||
p.kill()
|
||||
.make_assertion()
|
||||
|
|
|
@ -111,7 +111,7 @@ mod linux_only {
|
|||
use crate::common::util::*;
|
||||
|
||||
use std::fs::File;
|
||||
use std::process::Output;
|
||||
use std::process::{Output, Stdio};
|
||||
|
||||
fn make_broken_pipe() -> File {
|
||||
use libc::c_int;
|
||||
|
@ -135,6 +135,7 @@ mod linux_only {
|
|||
#[allow(deprecated)]
|
||||
let output = proc
|
||||
.ignore_stdin_write_error()
|
||||
.set_stdin(Stdio::piped())
|
||||
.run_no_wait()
|
||||
.pipe_in_and_wait_with_output(content.as_bytes());
|
||||
|
||||
|
|
|
@ -1105,6 +1105,7 @@ impl UCommand {
|
|||
"{}",
|
||||
MULTIPLE_STDIN_MEANINGLESS
|
||||
);
|
||||
self.set_stdin(Stdio::piped());
|
||||
self.bytes_into_stdin = Some(input.into());
|
||||
self
|
||||
}
|
||||
|
@ -1170,8 +1171,7 @@ impl UCommand {
|
|||
|
||||
let command = self
|
||||
.raw
|
||||
// TODO: use Stdio::null() as default to avoid accidental deadlocks ?
|
||||
.stdin(self.stdin.take().unwrap_or_else(Stdio::piped))
|
||||
.stdin(self.stdin.take().unwrap_or_else(Stdio::null))
|
||||
.stdout(Stdio::from(output.try_clone().unwrap()))
|
||||
.stderr(Stdio::from(output.try_clone().unwrap()));
|
||||
captured_stdout = Some(output);
|
||||
|
@ -1197,8 +1197,7 @@ impl UCommand {
|
|||
};
|
||||
|
||||
self.raw
|
||||
// TODO: use Stdio::null() as default to avoid accidental deadlocks ?
|
||||
.stdin(self.stdin.take().unwrap_or_else(Stdio::piped))
|
||||
.stdin(self.stdin.take().unwrap_or_else(Stdio::null))
|
||||
.stdout(stdout)
|
||||
.stderr(stderr)
|
||||
};
|
||||
|
@ -2696,7 +2695,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_uchild_when_pipe_in() {
|
||||
let ts = TestScenario::new("cat");
|
||||
let mut child = ts.ucmd().run_no_wait();
|
||||
let mut child = ts.ucmd().set_stdin(Stdio::piped()).run_no_wait();
|
||||
child.pipe_in("content");
|
||||
child.wait().unwrap().stdout_only("content").success();
|
||||
|
||||
|
@ -2721,6 +2720,7 @@ mod tests {
|
|||
|
||||
let mut child = ts
|
||||
.ucmd()
|
||||
.set_stdin(Stdio::piped())
|
||||
.stderr_to_stdout()
|
||||
.args(&["-riv", "a"])
|
||||
.run_no_wait();
|
||||
|
|
Loading…
Reference in a new issue