mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
add some tests for Clap's InferLongArgs setting
This commit is contained in:
parent
5f1933a89f
commit
2412e4cbf7
11 changed files with 166 additions and 110 deletions
|
@ -34,7 +34,7 @@ fn test_base32_encode_file() {
|
|||
|
||||
#[test]
|
||||
fn test_decode() {
|
||||
for decode_param in &["-d", "--decode"] {
|
||||
for decode_param in &["-d", "--decode", "--dec"] {
|
||||
let input = "JBSWY3DPFQQFO33SNRSCC===\n"; // spell-checker:disable-line
|
||||
new_ucmd!()
|
||||
.arg(decode_param)
|
||||
|
@ -56,7 +56,7 @@ fn test_garbage() {
|
|||
|
||||
#[test]
|
||||
fn test_ignore_garbage() {
|
||||
for ignore_garbage_param in &["-i", "--ignore-garbage"] {
|
||||
for ignore_garbage_param in &["-i", "--ignore-garbage", "--ig"] {
|
||||
let input = "JBSWY\x013DPFQ\x02QFO33SNRSCC===\n"; // spell-checker:disable-line
|
||||
new_ucmd!()
|
||||
.arg("-d")
|
||||
|
@ -69,7 +69,7 @@ fn test_ignore_garbage() {
|
|||
|
||||
#[test]
|
||||
fn test_wrap() {
|
||||
for wrap_param in &["-w", "--wrap"] {
|
||||
for wrap_param in &["-w", "--wrap", "--wr"] {
|
||||
let input = "The quick brown fox jumps over the lazy dog.";
|
||||
new_ucmd!()
|
||||
.arg(wrap_param)
|
||||
|
|
|
@ -26,7 +26,7 @@ fn test_base64_encode_file() {
|
|||
|
||||
#[test]
|
||||
fn test_decode() {
|
||||
for decode_param in &["-d", "--decode"] {
|
||||
for decode_param in &["-d", "--decode", "--dec"] {
|
||||
let input = "aGVsbG8sIHdvcmxkIQ=="; // spell-checker:disable-line
|
||||
new_ucmd!()
|
||||
.arg(decode_param)
|
||||
|
@ -48,7 +48,7 @@ fn test_garbage() {
|
|||
|
||||
#[test]
|
||||
fn test_ignore_garbage() {
|
||||
for ignore_garbage_param in &["-i", "--ignore-garbage"] {
|
||||
for ignore_garbage_param in &["-i", "--ignore-garbage", "--ig"] {
|
||||
let input = "aGVsbG8sIHdvcmxkIQ==\0"; // spell-checker:disable-line
|
||||
new_ucmd!()
|
||||
.arg("-d")
|
||||
|
@ -61,7 +61,7 @@ fn test_ignore_garbage() {
|
|||
|
||||
#[test]
|
||||
fn test_wrap() {
|
||||
for wrap_param in &["-w", "--wrap"] {
|
||||
for wrap_param in &["-w", "--wrap", "--wr"] {
|
||||
let input = "The quick brown fox jumps over the lazy dog.";
|
||||
new_ucmd!()
|
||||
.arg(wrap_param)
|
||||
|
|
|
@ -61,7 +61,7 @@ fn test_do_not_remove_suffix() {
|
|||
|
||||
#[test]
|
||||
fn test_multiple_param() {
|
||||
for &multiple_param in &["-a", "--multiple"] {
|
||||
for &multiple_param in &["-a", "--multiple", "--mul"] {
|
||||
let path = "/foo/bar/baz";
|
||||
new_ucmd!()
|
||||
.args(&[multiple_param, path, path])
|
||||
|
@ -72,7 +72,7 @@ fn test_multiple_param() {
|
|||
|
||||
#[test]
|
||||
fn test_suffix_param() {
|
||||
for &suffix_param in &["-s", "--suffix"] {
|
||||
for &suffix_param in &["-s", "--suffix", "--suf"] {
|
||||
let path = "/foo/bar/baz.exe";
|
||||
new_ucmd!()
|
||||
.args(&[suffix_param, ".exe", path, path])
|
||||
|
@ -83,7 +83,7 @@ fn test_suffix_param() {
|
|||
|
||||
#[test]
|
||||
fn test_zero_param() {
|
||||
for &zero_param in &["-z", "--zero"] {
|
||||
for &zero_param in &["-z", "--zero", "--ze"] {
|
||||
let path = "/foo/bar/baz";
|
||||
new_ucmd!()
|
||||
.args(&[zero_param, "-a", path, path])
|
||||
|
|
|
@ -264,7 +264,7 @@ fn test_numbered_lines_no_trailing_newline() {
|
|||
|
||||
#[test]
|
||||
fn test_stdin_show_nonprinting() {
|
||||
for same_param in &["-v", "--show-nonprinting"] {
|
||||
for same_param in &["-v", "--show-nonprinting", "--show-non"] {
|
||||
new_ucmd!()
|
||||
.args(&[same_param])
|
||||
.pipe_in("\t\0\n")
|
||||
|
@ -275,7 +275,7 @@ fn test_stdin_show_nonprinting() {
|
|||
|
||||
#[test]
|
||||
fn test_stdin_show_tabs() {
|
||||
for same_param in &["-T", "--show-tabs"] {
|
||||
for same_param in &["-T", "--show-tabs", "--show-ta"] {
|
||||
new_ucmd!()
|
||||
.args(&[same_param])
|
||||
.pipe_in("\t\0\n")
|
||||
|
@ -286,7 +286,7 @@ fn test_stdin_show_tabs() {
|
|||
|
||||
#[test]
|
||||
fn test_stdin_show_ends() {
|
||||
for &same_param in &["-E", "--show-ends"] {
|
||||
for &same_param in &["-E", "--show-ends", "--show-e"] {
|
||||
new_ucmd!()
|
||||
.args(&[same_param, "-"])
|
||||
.pipe_in("\t\0\n\t")
|
||||
|
@ -317,7 +317,7 @@ fn test_show_ends_crlf() {
|
|||
|
||||
#[test]
|
||||
fn test_stdin_show_all() {
|
||||
for same_param in &["-A", "--show-all"] {
|
||||
for same_param in &["-A", "--show-all", "--show-a"] {
|
||||
new_ucmd!()
|
||||
.args(&[same_param])
|
||||
.pipe_in("\t\0\n")
|
||||
|
@ -346,7 +346,7 @@ fn test_stdin_nonprinting_and_tabs() {
|
|||
|
||||
#[test]
|
||||
fn test_stdin_squeeze_blank() {
|
||||
for same_param in &["-s", "--squeeze-blank"] {
|
||||
for same_param in &["-s", "--squeeze-blank", "--squeeze"] {
|
||||
new_ucmd!()
|
||||
.arg(same_param)
|
||||
.pipe_in("\n\na\n\n\n\n\nb\n\n\n")
|
||||
|
@ -358,7 +358,7 @@ fn test_stdin_squeeze_blank() {
|
|||
#[test]
|
||||
fn test_stdin_number_non_blank() {
|
||||
// spell-checker:disable-next-line
|
||||
for same_param in &["-b", "--number-nonblank"] {
|
||||
for same_param in &["-b", "--number-nonblank", "--number-non"] {
|
||||
new_ucmd!()
|
||||
.arg(same_param)
|
||||
.arg("-")
|
||||
|
|
|
@ -60,7 +60,7 @@ fn test_1() {
|
|||
#[test]
|
||||
fn test_fail_silently() {
|
||||
if get_effective_gid() != 0 {
|
||||
for opt in &["-f", "--silent", "--quiet"] {
|
||||
for opt in &["-f", "--silent", "--quiet", "--sil", "--qui"] {
|
||||
new_ucmd!()
|
||||
.arg(opt)
|
||||
.arg("bin")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE
|
||||
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob
|
||||
|
||||
use crate::common::util::*;
|
||||
#[cfg(not(windows))]
|
||||
|
@ -227,6 +227,17 @@ fn test_cp_arg_no_clobber() {
|
|||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cp_arg_no_clobber_inferred_arg() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
|
||||
.arg(TEST_HOW_ARE_YOU_SOURCE)
|
||||
.arg("--no-clob")
|
||||
.succeeds();
|
||||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cp_arg_no_clobber_twice() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
|
|
|
@ -41,7 +41,7 @@ static COMPLEX_SEQUENCE: &TestedSequence = &TestedSequence {
|
|||
|
||||
#[test]
|
||||
fn test_byte_sequence() {
|
||||
for ¶m in &["-b", "--bytes"] {
|
||||
for ¶m in &["-b", "--bytes", "--byt"] {
|
||||
for example_seq in EXAMPLE_SEQUENCES {
|
||||
new_ucmd!()
|
||||
.args(&[param, example_seq.sequence, INPUT])
|
||||
|
@ -53,7 +53,7 @@ fn test_byte_sequence() {
|
|||
|
||||
#[test]
|
||||
fn test_char_sequence() {
|
||||
for ¶m in &["-c", "--characters"] {
|
||||
for ¶m in &["-c", "--characters", "--char"] {
|
||||
for example_seq in EXAMPLE_SEQUENCES {
|
||||
//as of coreutils 8.25 a char range is effectively the same as a byte range; there is no distinct treatment of utf8 chars.
|
||||
new_ucmd!()
|
||||
|
@ -66,7 +66,7 @@ fn test_char_sequence() {
|
|||
|
||||
#[test]
|
||||
fn test_field_sequence() {
|
||||
for ¶m in &["-f", "--fields"] {
|
||||
for ¶m in &["-f", "--fields", "--fie"] {
|
||||
for example_seq in EXAMPLE_SEQUENCES {
|
||||
new_ucmd!()
|
||||
.args(&[param, example_seq.sequence, INPUT])
|
||||
|
@ -78,7 +78,7 @@ fn test_field_sequence() {
|
|||
|
||||
#[test]
|
||||
fn test_specify_delimiter() {
|
||||
for ¶m in &["-d", "--delimiter"] {
|
||||
for ¶m in &["-d", "--delimiter", "--del"] {
|
||||
new_ucmd!()
|
||||
.args(&[param, ":", "-f", COMPLEX_SEQUENCE.sequence, INPUT])
|
||||
.succeeds()
|
||||
|
@ -100,16 +100,29 @@ fn test_output_delimiter() {
|
|||
])
|
||||
.succeeds()
|
||||
.stdout_only_fixture("output_delimiter.expected");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&[
|
||||
"-d:",
|
||||
"--output-del=@",
|
||||
"-f",
|
||||
COMPLEX_SEQUENCE.sequence,
|
||||
INPUT,
|
||||
])
|
||||
.succeeds()
|
||||
.stdout_only_fixture("output_delimiter.expected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_complement() {
|
||||
for param in &["--complement", "--com"] {
|
||||
new_ucmd!()
|
||||
.args(&["-d_", "--complement", "-f", "2"])
|
||||
.args(&["-d_", param, "-f", "2"])
|
||||
.pipe_in("9_1\n8_2\n7_3")
|
||||
.succeeds()
|
||||
.stdout_only("9\n8\n7\n");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_zero_terminated() {
|
||||
|
@ -122,7 +135,7 @@ fn test_zero_terminated() {
|
|||
|
||||
#[test]
|
||||
fn test_only_delimited() {
|
||||
for param in &["-s", "--only-delimited"] {
|
||||
for param in &["-s", "--only-delimited", "--only-del"] {
|
||||
new_ucmd!()
|
||||
.args(&["-d_", param, "-f", "1"])
|
||||
.pipe_in("91\n82\n7_3")
|
||||
|
|
|
@ -7,12 +7,9 @@ use rust_users::*;
|
|||
|
||||
#[test]
|
||||
fn test_date_email() {
|
||||
new_ucmd!().arg("--rfc-email").succeeds();
|
||||
for param in &["--rfc-email", "--rfc-e", "-R"] {
|
||||
new_ucmd!().arg(param).succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_email2() {
|
||||
new_ucmd!().arg("-R").succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -26,37 +23,40 @@ fn test_date_rfc_3339() {
|
|||
let re = Regex::new(rfc_regexp).unwrap();
|
||||
|
||||
// Check that the output matches the regexp
|
||||
for param in &["--rfc-3339", "--rfc-3"] {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--rfc-3339=ns")
|
||||
.arg(format!("{}=ns", param))
|
||||
.succeeds()
|
||||
.stdout_matches(&re);
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--rfc-3339=seconds")
|
||||
.arg(format!("{}=seconds", param))
|
||||
.succeeds()
|
||||
.stdout_matches(&re);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_rfc_8601() {
|
||||
new_ucmd!().arg("--iso-8601=ns").succeeds();
|
||||
for param in &["--iso-8601", "--i"] {
|
||||
new_ucmd!().arg(format!("{}=ns", param)).succeeds();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_rfc_8601_second() {
|
||||
new_ucmd!().arg("--iso-8601=second").succeeds();
|
||||
for param in &["--iso-8601", "--i"] {
|
||||
new_ucmd!().arg(format!("{}=second", param)).succeeds();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_utc() {
|
||||
new_ucmd!().arg("--utc").succeeds();
|
||||
for param in &["--universal", "--utc", "--uni", "--u"] {
|
||||
new_ucmd!().arg(param).succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_universal() {
|
||||
new_ucmd!().arg("--universal").succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -5,6 +5,11 @@ fn test_df_compatible_no_size_arg() {
|
|||
new_ucmd!().arg("-a").succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_df_shortened_long_argument() {
|
||||
new_ucmd!().arg("--a").succeeds();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_df_compatible() {
|
||||
new_ucmd!().arg("-ah").succeeds();
|
||||
|
|
|
@ -27,6 +27,28 @@ lazy_static! {
|
|||
static ref UMASK_MUTEX: Mutex<()> = Mutex::new(());
|
||||
}
|
||||
|
||||
const LONG_ARGS: &[&str] = &[
|
||||
"-l",
|
||||
"--long",
|
||||
"--l",
|
||||
"--format=long",
|
||||
"--for=long",
|
||||
"--format=verbose",
|
||||
"--for=verbose",
|
||||
];
|
||||
|
||||
const ACROSS_ARGS: &[&str] = &[
|
||||
"-x",
|
||||
"--format=across",
|
||||
"--format=horizontal",
|
||||
"--for=across",
|
||||
"--for=horizontal",
|
||||
];
|
||||
|
||||
const COMMA_ARGS: &[&str] = &["-m", "--format=commas", "--for=commas"];
|
||||
|
||||
const COLUMN_ARGS: &[&str] = &["-C", "--format=columns", "--for=columns"];
|
||||
|
||||
#[test]
|
||||
fn test_ls_ls() {
|
||||
new_ucmd!().succeeds();
|
||||
|
@ -315,7 +337,13 @@ fn test_ls_width() {
|
|||
at.touch(&at.plus_as_string("test-width-3"));
|
||||
at.touch(&at.plus_as_string("test-width-4"));
|
||||
|
||||
for option in &["-w 100", "-w=100", "--width=100", "--width 100"] {
|
||||
for option in &[
|
||||
"-w 100",
|
||||
"-w=100",
|
||||
"--width=100",
|
||||
"--width 100",
|
||||
"--wid=100",
|
||||
] {
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&option.split(' ').collect::<Vec<_>>())
|
||||
|
@ -324,7 +352,7 @@ fn test_ls_width() {
|
|||
.stdout_only("test-width-1 test-width-2 test-width-3 test-width-4\n");
|
||||
}
|
||||
|
||||
for option in &["-w 50", "-w=50", "--width=50", "--width 50"] {
|
||||
for option in &["-w 50", "-w=50", "--width=50", "--width 50", "--wid=50"] {
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&option.split(' ').collect::<Vec<_>>())
|
||||
|
@ -333,7 +361,7 @@ fn test_ls_width() {
|
|||
.stdout_only("test-width-1 test-width-3\ntest-width-2 test-width-4\n");
|
||||
}
|
||||
|
||||
for option in &["-w 25", "-w=25", "--width=25", "--width 25"] {
|
||||
for option in &["-w 25", "-w=25", "--width=25", "--width 25", "--wid=25"] {
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&option.split(' ').collect::<Vec<_>>())
|
||||
|
@ -342,7 +370,7 @@ fn test_ls_width() {
|
|||
.stdout_only("test-width-1\ntest-width-2\ntest-width-3\ntest-width-4\n");
|
||||
}
|
||||
|
||||
for option in &["-w 0", "-w=0", "--width=0", "--width 0"] {
|
||||
for option in &["-w 0", "-w=0", "--width=0", "--width 0", "--wid=0"] {
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&option.split(' ').collect::<Vec<_>>())
|
||||
|
@ -358,7 +386,7 @@ fn test_ls_width() {
|
|||
.fails()
|
||||
.stderr_contains("invalid line width");
|
||||
|
||||
for option in &["-w 1a", "-w=1a", "--width=1a", "--width 1a"] {
|
||||
for option in &["-w 1a", "-w=1a", "--width=1a", "--width 1a", "--wid 1a"] {
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&option.split(' ').collect::<Vec<_>>())
|
||||
|
@ -382,12 +410,12 @@ fn test_ls_columns() {
|
|||
|
||||
result.stdout_only("test-columns-1\ntest-columns-2\ntest-columns-3\ntest-columns-4\n");
|
||||
|
||||
for option in &["-C", "--format=columns"] {
|
||||
for option in COLUMN_ARGS {
|
||||
let result = scene.ucmd().arg(option).succeeds();
|
||||
result.stdout_only("test-columns-1 test-columns-2 test-columns-3 test-columns-4\n");
|
||||
}
|
||||
|
||||
for option in &["-C", "--format=columns"] {
|
||||
for option in COLUMN_ARGS {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-w=40")
|
||||
|
@ -400,7 +428,7 @@ fn test_ls_columns() {
|
|||
// environment variable.
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
for option in &["-C", "--format=columns"] {
|
||||
for option in COLUMN_ARGS {
|
||||
scene
|
||||
.ucmd()
|
||||
.env("COLUMNS", "40")
|
||||
|
@ -438,14 +466,14 @@ fn test_ls_across() {
|
|||
at.touch(&at.plus_as_string("test-across-3"));
|
||||
at.touch(&at.plus_as_string("test-across-4"));
|
||||
|
||||
for option in &["-x", "--format=across"] {
|
||||
for option in ACROSS_ARGS {
|
||||
let result = scene.ucmd().arg(option).succeeds();
|
||||
// Because the test terminal has width 0, this is the same output as
|
||||
// the columns option.
|
||||
result.stdout_only("test-across-1 test-across-2 test-across-3 test-across-4\n");
|
||||
}
|
||||
|
||||
for option in &["-x", "--format=across"] {
|
||||
for option in ACROSS_ARGS {
|
||||
// Because the test terminal has width 0, this is the same output as
|
||||
// the columns option.
|
||||
scene
|
||||
|
@ -466,12 +494,12 @@ fn test_ls_commas() {
|
|||
at.touch(&at.plus_as_string("test-commas-3"));
|
||||
at.touch(&at.plus_as_string("test-commas-4"));
|
||||
|
||||
for option in &["-m", "--format=commas"] {
|
||||
for option in COMMA_ARGS {
|
||||
let result = scene.ucmd().arg(option).succeeds();
|
||||
result.stdout_only("test-commas-1, test-commas-2, test-commas-3, test-commas-4\n");
|
||||
}
|
||||
|
||||
for option in &["-m", "--format=commas"] {
|
||||
for option in COMMA_ARGS {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-w=30")
|
||||
|
@ -479,7 +507,7 @@ fn test_ls_commas() {
|
|||
.succeeds()
|
||||
.stdout_only("test-commas-1, test-commas-2,\ntest-commas-3, test-commas-4\n");
|
||||
}
|
||||
for option in &["-m", "--format=commas"] {
|
||||
for option in COMMA_ARGS {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-w=45")
|
||||
|
@ -507,7 +535,7 @@ fn test_ls_long() {
|
|||
let at = &scene.fixtures;
|
||||
at.touch(&at.plus_as_string("test-long"));
|
||||
|
||||
for arg in &["-l", "--long", "--format=long", "--format=verbose"] {
|
||||
for arg in LONG_ARGS {
|
||||
let result = scene.ucmd().arg(arg).arg("test-long").succeeds();
|
||||
#[cfg(not(windows))]
|
||||
result.stdout_contains("-rw-rw-r--");
|
||||
|
@ -533,7 +561,7 @@ fn test_ls_long_format() {
|
|||
at.touch(&at.plus_as_string("test-long-dir/test-long-file"));
|
||||
at.mkdir(&at.plus_as_string("test-long-dir/test-long-dir"));
|
||||
|
||||
for arg in &["-l", "--long", "--format=long", "--format=verbose"] {
|
||||
for arg in LONG_ARGS {
|
||||
// Assuming sane username do not have spaces within them.
|
||||
// A line of the output should be:
|
||||
// One of the characters -bcCdDlMnpPsStTx?
|
||||
|
@ -808,7 +836,7 @@ fn test_ls_long_total_size() {
|
|||
.collect()
|
||||
};
|
||||
|
||||
for arg in &["-l", "--long", "--format=long", "--format=verbose"] {
|
||||
for arg in LONG_ARGS {
|
||||
let result = scene.ucmd().arg(arg).succeeds();
|
||||
result.stdout_contains(expected_prints["long_vanilla"]);
|
||||
|
||||
|
@ -1383,20 +1411,14 @@ fn test_ls_color() {
|
|||
assert!(!result.stdout_str().contains(z_with_colors));
|
||||
|
||||
// Color should be enabled
|
||||
for param in &["--color", "--col", "--color=always", "--col=always"] {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--color")
|
||||
.succeeds()
|
||||
.stdout_contains(a_with_colors)
|
||||
.stdout_contains(z_with_colors);
|
||||
|
||||
// Color should be enabled
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--color=always")
|
||||
.arg(param)
|
||||
.succeeds()
|
||||
.stdout_contains(a_with_colors)
|
||||
.stdout_contains(z_with_colors);
|
||||
}
|
||||
|
||||
// Color should be disabled
|
||||
let result = scene.ucmd().arg("--color=never").succeeds();
|
||||
|
@ -1492,24 +1514,21 @@ fn test_ls_indicator_style() {
|
|||
assert!(at.is_fifo("named-pipe.fifo"));
|
||||
|
||||
// Classify, File-Type, and Slash all contain indicators for directories.
|
||||
let options = vec!["classify", "file-type", "slash"];
|
||||
for opt in options {
|
||||
for opt in [
|
||||
"--indicator-style=classify",
|
||||
"--ind=classify",
|
||||
"--indicator-style=file-type",
|
||||
"--ind=file-type",
|
||||
"--indicator-style=slash",
|
||||
"--ind=slash",
|
||||
"--classify",
|
||||
"--class",
|
||||
"--file-type",
|
||||
"--file",
|
||||
"-p",
|
||||
] {
|
||||
// Verify that classify and file-type both contain indicators for symlinks.
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("--indicator-style={}", opt))
|
||||
.succeeds()
|
||||
.stdout_contains(&"/");
|
||||
}
|
||||
|
||||
// Same test as above, but with the alternate flags.
|
||||
let options = vec!["--classify", "--file-type", "-p"];
|
||||
for opt in options {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(opt.to_string())
|
||||
.succeeds()
|
||||
.stdout_contains(&"/");
|
||||
scene.ucmd().arg(opt).succeeds().stdout_contains(&"/");
|
||||
}
|
||||
|
||||
// Classify and File-Type all contain indicators for pipes and links.
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::common::util::*;
|
|||
#[test]
|
||||
fn test_count() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-q", "--count"] {
|
||||
for opt in &["-q", "--count", "--c"] {
|
||||
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ fn test_count() {
|
|||
#[test]
|
||||
fn test_boot() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-b", "--boot"] {
|
||||
for opt in &["-b", "--boot", "--b"] {
|
||||
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ fn test_boot() {
|
|||
#[test]
|
||||
fn test_heading() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-H", "--heading"] {
|
||||
for opt in &["-H", "--heading", "--head"] {
|
||||
// allow whitespace variation
|
||||
// * minor whitespace differences occur between platform built-in outputs;
|
||||
// specifically number of TABs between "TIME" and "COMMENT" may be variant
|
||||
|
@ -49,7 +49,7 @@ fn test_heading() {
|
|||
#[test]
|
||||
fn test_short() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-s", "--short"] {
|
||||
for opt in &["-s", "--short", "--s"] {
|
||||
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ fn test_short() {
|
|||
#[test]
|
||||
fn test_login() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-l", "--login"] {
|
||||
for opt in &["-l", "--login", "--log"] {
|
||||
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ fn test_m() {
|
|||
#[test]
|
||||
fn test_process() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-p", "--process"] {
|
||||
for opt in &["-p", "--process", "--p"] {
|
||||
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ fn test_process() {
|
|||
#[test]
|
||||
fn test_runlevel() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-r", "--runlevel"] {
|
||||
for opt in &["-r", "--runlevel", "--r"] {
|
||||
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
||||
|
||||
|
@ -102,7 +102,7 @@ fn test_runlevel() {
|
|||
#[test]
|
||||
fn test_time() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-t", "--time"] {
|
||||
for opt in &["-t", "--time", "--t"] {
|
||||
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
||||
}
|
||||
|
@ -118,7 +118,15 @@ fn test_mesg() {
|
|||
// --writable
|
||||
// same as -T
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-T", "-w", "--mesg", "--message", "--writable"] {
|
||||
for opt in &[
|
||||
"-T",
|
||||
"-w",
|
||||
"--mesg",
|
||||
"--m",
|
||||
"--message",
|
||||
"--writable",
|
||||
"--w",
|
||||
] {
|
||||
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
||||
}
|
||||
|
@ -146,7 +154,7 @@ fn test_too_many_args() {
|
|||
#[test]
|
||||
fn test_users() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-u", "--users"] {
|
||||
for opt in &["-u", "--users", "--us"] {
|
||||
let actual = ts.ucmd().arg(opt).succeeds().stdout_move_str();
|
||||
let expect = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
println!("actual: {:?}", actual);
|
||||
|
@ -180,7 +188,7 @@ fn test_lookup() {
|
|||
#[test]
|
||||
fn test_dead() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-d", "--dead"] {
|
||||
for opt in &["-d", "--dead", "--de"] {
|
||||
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
||||
}
|
||||
|
@ -212,7 +220,7 @@ fn test_all() {
|
|||
}
|
||||
|
||||
let ts = TestScenario::new(util_name!());
|
||||
for opt in &["-a", "--all"] {
|
||||
for opt in &["-a", "--all", "--a"] {
|
||||
let expected_stdout = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
ts.ucmd().arg(opt).succeeds().stdout_is(expected_stdout);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue