mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
stdbuf: move from getopts to clap
This commit is contained in:
parent
9ae4928b7b
commit
c54b5f2d82
4 changed files with 175 additions and 156 deletions
|
@ -1,13 +1,71 @@
|
|||
#[cfg(not(target_os = "windows"))]
|
||||
use crate::common::util::*;
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[test]
|
||||
fn test_stdbuf_unbuffered_stdout() {
|
||||
if cfg!(target_os = "linux") {
|
||||
// This is a basic smoke test
|
||||
new_ucmd!()
|
||||
.args(&["-o0", "head"])
|
||||
.pipe_in("The quick brown fox jumps over the lazy dog.")
|
||||
.run()
|
||||
.stdout_is("The quick brown fox jumps over the lazy dog.");
|
||||
}
|
||||
// This is a basic smoke test
|
||||
new_ucmd!()
|
||||
.args(&["-o0", "head"])
|
||||
.pipe_in("The quick brown fox jumps over the lazy dog.")
|
||||
.run()
|
||||
.stdout_is("The quick brown fox jumps over the lazy dog.");
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[test]
|
||||
fn test_stdbuf_line_buffered_stdout() {
|
||||
new_ucmd!()
|
||||
.args(&["-oL", "head"])
|
||||
.pipe_in("The quick brown fox jumps over the lazy dog.")
|
||||
.run()
|
||||
.stdout_is("The quick brown fox jumps over the lazy dog.");
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[test]
|
||||
fn test_stdbuf_no_buffer_option_fails() {
|
||||
new_ucmd!()
|
||||
.args(&["head"])
|
||||
.pipe_in("The quick brown fox jumps over the lazy dog.")
|
||||
.fails()
|
||||
.stderr_is(
|
||||
"error: The following required arguments were not provided:\n \
|
||||
--error <MODE>\n \
|
||||
--input <MODE>\n \
|
||||
--output <MODE>\n\n\
|
||||
USAGE:\n \
|
||||
stdbuf OPTION... COMMAND\n\n\
|
||||
For more information try --help",
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[test]
|
||||
fn test_stdbuf_trailing_var_arg() {
|
||||
new_ucmd!()
|
||||
.args(&["-i", "1024", "tail", "-1"])
|
||||
.pipe_in("The quick brown fox\njumps over the lazy dog.")
|
||||
.run()
|
||||
.stdout_is("jumps over the lazy dog.");
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[test]
|
||||
fn test_stdbuf_line_buffering_stdin_fails() {
|
||||
new_ucmd!()
|
||||
.args(&["-i", "L", "head"])
|
||||
.pipe_in("The quick brown fox jumps over the lazy dog.")
|
||||
.fails()
|
||||
.stderr_is("stdbuf: error: line buffering stdin is meaningless\nTry 'stdbuf --help' for more information.");
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[test]
|
||||
fn test_stdbuf_invalid_mode_fails() {
|
||||
new_ucmd!()
|
||||
.args(&["-i", "1024R", "head"])
|
||||
.pipe_in("The quick brown fox jumps over the lazy dog.")
|
||||
.fails()
|
||||
.stderr_is("stdbuf: error: invalid mode 1024R\nTry 'stdbuf --help' for more information.");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue