mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
tests/tty: fix test inputs
calling `pipe_in("</dev/null")` does not pipe in the `/dev/null` file, but the raw string "</dev/null". Closes https://github.com/uutils/coreutils/issues/2301
This commit is contained in:
parent
3c271304f5
commit
aeaf2cebfb
1 changed files with 27 additions and 19 deletions
|
@ -1,11 +1,14 @@
|
||||||
|
use std::fs::File;
|
||||||
|
|
||||||
use crate::common::util::*;
|
use crate::common::util::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
fn test_dev_null() {
|
fn test_dev_null() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.pipe_in("</dev/null")
|
.set_stdin(File::open("/dev/null").unwrap())
|
||||||
.fails()
|
.fails()
|
||||||
|
.code_is(1)
|
||||||
.stdout_is("not a tty\n");
|
.stdout_is("not a tty\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,44 +17,49 @@ fn test_dev_null() {
|
||||||
fn test_dev_null_silent() {
|
fn test_dev_null_silent() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-s"])
|
.args(&["-s"])
|
||||||
.pipe_in("</dev/null")
|
.set_stdin(File::open("/dev/null").unwrap())
|
||||||
.fails()
|
.fails()
|
||||||
|
.code_is(1)
|
||||||
.stdout_is("");
|
.stdout_is("");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_close_stdin() {
|
fn test_close_stdin() {
|
||||||
new_ucmd!().pipe_in("<&-").fails().stdout_is("not a tty\n");
|
let mut child = new_ucmd!().run_no_wait();
|
||||||
|
drop(child.stdin.take());
|
||||||
|
let output = child.wait_with_output().unwrap();
|
||||||
|
assert_eq!(output.status.code(), Some(1));
|
||||||
|
assert_eq!(std::str::from_utf8(&output.stdout), Ok("not a tty\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_close_stdin_silent() {
|
fn test_close_stdin_silent() {
|
||||||
new_ucmd!()
|
let mut child = new_ucmd!().arg("-s").run_no_wait();
|
||||||
.args(&["-s"])
|
drop(child.stdin.take());
|
||||||
.pipe_in("<&-")
|
let output = child.wait_with_output().unwrap();
|
||||||
.fails()
|
assert_eq!(output.status.code(), Some(1));
|
||||||
.stdout_is("");
|
assert!(output.stdout.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_close_stdin_silent_long() {
|
fn test_close_stdin_silent_long() {
|
||||||
new_ucmd!()
|
let mut child = new_ucmd!().arg("--silent").run_no_wait();
|
||||||
.args(&["--silent"])
|
drop(child.stdin.take());
|
||||||
.pipe_in("<&-")
|
let output = child.wait_with_output().unwrap();
|
||||||
.fails()
|
assert_eq!(output.status.code(), Some(1));
|
||||||
.stdout_is("");
|
assert!(output.stdout.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_close_stdin_silent_alias() {
|
fn test_close_stdin_silent_alias() {
|
||||||
new_ucmd!()
|
let mut child = new_ucmd!().arg("--quiet").run_no_wait();
|
||||||
.args(&["--quiet"])
|
drop(child.stdin.take());
|
||||||
.pipe_in("<&-")
|
let output = child.wait_with_output().unwrap();
|
||||||
.fails()
|
assert_eq!(output.status.code(), Some(1));
|
||||||
.stdout_is("");
|
assert!(output.stdout.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_wrong_argument() {
|
fn test_wrong_argument() {
|
||||||
new_ucmd!().args(&["a"]).fails();
|
new_ucmd!().args(&["a"]).fails().code_is(2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue