1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tty: Move from getopts to clap (#1956)

+ tty: Add some tests
This commit is contained in:
Dominik Bittner 2021-03-29 13:00:47 +02:00 committed by GitHub
parent 88d0bb01c0
commit 3714e2201b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 100 additions and 50 deletions

View file

@ -1 +1,57 @@
// ToDO: add tests
use crate::common::util::*;
#[test]
#[cfg(not(windows))]
fn test_dev_null() {
new_ucmd!()
.pipe_in("</dev/null")
.fails()
.stdout_is("not a tty\n");
}
#[test]
#[cfg(not(windows))]
fn test_dev_null_silent() {
new_ucmd!()
.args(&["-s"])
.pipe_in("</dev/null")
.fails()
.stdout_is("");
}
#[test]
fn test_close_stdin() {
new_ucmd!().pipe_in("<&-").fails().stdout_is("not a tty\n");
}
#[test]
fn test_close_stdin_silent() {
new_ucmd!()
.args(&["-s"])
.pipe_in("<&-")
.fails()
.stdout_is("");
}
#[test]
fn test_close_stdin_silent_long() {
new_ucmd!()
.args(&["--silent"])
.pipe_in("<&-")
.fails()
.stdout_is("");
}
#[test]
fn test_close_stdin_silent_alias() {
new_ucmd!()
.args(&["--quiet"])
.pipe_in("<&-")
.fails()
.stdout_is("");
}
#[test]
fn test_wrong_argument() {
new_ucmd!().args(&["a"]).fails();
}