mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 20:47:46 +00:00
Merge branch 'master' into who_fix_runlevel
This commit is contained in:
commit
7bf076505f
20 changed files with 558 additions and 235 deletions
|
@ -129,6 +129,15 @@ fn test_zero_terminated_syntax_2() {
|
|||
.stdout_is("x\0y");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_zero_terminated_negative_lines() {
|
||||
new_ucmd!()
|
||||
.args(&["-z", "-n", "-1"])
|
||||
.pipe_in("x\0y\0z\0")
|
||||
.run()
|
||||
.stdout_is("x\0y\0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_negative_byte_syntax() {
|
||||
new_ucmd!()
|
||||
|
|
|
@ -281,6 +281,7 @@ fn test_leading_whitespace_in_free_argument_should_imply_padding() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_should_calculate_implicit_padding_per_free_argument() {
|
||||
new_ucmd!()
|
||||
.args(&["--from=auto", " 1Ki", " 2K"])
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
use crate::common::util::*;
|
||||
|
||||
fn test_helper(file_name: &str, args: &str) {
|
||||
new_ucmd!()
|
||||
.arg(format!("{}.txt", file_name))
|
||||
.args(&args.split(' ').collect::<Vec<&str>>())
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("{}.expected", file_name));
|
||||
fn test_helper(file_name: &str, possible_args: &[&str]) {
|
||||
for args in possible_args {
|
||||
new_ucmd!()
|
||||
.arg(format!("{}.txt", file_name))
|
||||
.args(&args.split(' ').collect::<Vec<&str>>())
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("{}.expected", file_name));
|
||||
|
||||
new_ucmd!()
|
||||
.arg(format!("{}.txt", file_name))
|
||||
.arg("--debug")
|
||||
.args(&args.split(' ').collect::<Vec<&str>>())
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("{}.expected.debug", file_name));
|
||||
new_ucmd!()
|
||||
.arg(format!("{}.txt", file_name))
|
||||
.arg("--debug")
|
||||
.args(&args.split(' ').collect::<Vec<&str>>())
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("{}.expected.debug", file_name));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -71,7 +73,7 @@ fn test_extsort_zero_terminated() {
|
|||
|
||||
#[test]
|
||||
fn test_months_whitespace() {
|
||||
test_helper("months-whitespace", "-M");
|
||||
test_helper("months-whitespace", &["-M", "--month-sort", "--sort=month"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -85,7 +87,10 @@ fn test_version_empty_lines() {
|
|||
|
||||
#[test]
|
||||
fn test_human_numeric_whitespace() {
|
||||
test_helper("human-numeric-whitespace", "-h");
|
||||
test_helper(
|
||||
"human-numeric-whitespace",
|
||||
&["-h", "--human-numeric-sort", "--sort=human-numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
// This tests where serde often fails when reading back JSON
|
||||
|
@ -102,12 +107,18 @@ fn test_extsort_as64_bailout() {
|
|||
|
||||
#[test]
|
||||
fn test_multiple_decimals_general() {
|
||||
test_helper("multiple_decimals_general", "-g")
|
||||
test_helper(
|
||||
"multiple_decimals_general",
|
||||
&["-g", "--general-numeric-sort", "--sort=general-numeric"],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multiple_decimals_numeric() {
|
||||
test_helper("multiple_decimals_numeric", "-n")
|
||||
test_helper(
|
||||
"multiple_decimals_numeric",
|
||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -186,72 +197,93 @@ fn test_random_shuffle_contains_two_runs_not_the_same() {
|
|||
|
||||
#[test]
|
||||
fn test_numeric_floats_and_ints() {
|
||||
test_helper("numeric_floats_and_ints", "-n");
|
||||
test_helper(
|
||||
"numeric_floats_and_ints",
|
||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_numeric_floats() {
|
||||
test_helper("numeric_floats", "-n");
|
||||
test_helper(
|
||||
"numeric_floats",
|
||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_numeric_floats_with_nan() {
|
||||
test_helper("numeric_floats_with_nan", "-n");
|
||||
test_helper(
|
||||
"numeric_floats_with_nan",
|
||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_numeric_unfixed_floats() {
|
||||
test_helper("numeric_unfixed_floats", "-n");
|
||||
test_helper(
|
||||
"numeric_unfixed_floats",
|
||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_numeric_fixed_floats() {
|
||||
test_helper("numeric_fixed_floats", "-n");
|
||||
test_helper(
|
||||
"numeric_fixed_floats",
|
||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_numeric_unsorted_ints() {
|
||||
test_helper("numeric_unsorted_ints", "-n");
|
||||
test_helper(
|
||||
"numeric_unsorted_ints",
|
||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_human_block_sizes() {
|
||||
test_helper("human_block_sizes", "-h");
|
||||
test_helper(
|
||||
"human_block_sizes",
|
||||
&["-h", "--human-numeric-sort", "--sort=human-numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_month_default() {
|
||||
test_helper("month_default", "-M");
|
||||
test_helper("month_default", &["-M", "--month-sort", "--sort=month"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_month_stable() {
|
||||
test_helper("month_stable", "-Ms");
|
||||
test_helper("month_stable", &["-Ms"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_default_unsorted_ints() {
|
||||
test_helper("default_unsorted_ints", "");
|
||||
test_helper("default_unsorted_ints", &[""]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_numeric_unique_ints() {
|
||||
test_helper("numeric_unsorted_ints_unique", "-nu");
|
||||
test_helper("numeric_unsorted_ints_unique", &["-nu"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version() {
|
||||
test_helper("version", "-V");
|
||||
test_helper("version", &["-V"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ignore_case() {
|
||||
test_helper("ignore_case", "-f");
|
||||
test_helper("ignore_case", &["-f"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dictionary_order() {
|
||||
test_helper("dictionary_order", "-d");
|
||||
test_helper("dictionary_order", &["-d"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -278,47 +310,53 @@ fn test_non_printing_chars() {
|
|||
|
||||
#[test]
|
||||
fn test_exponents_positive_general_fixed() {
|
||||
test_helper("exponents_general", "-g");
|
||||
test_helper("exponents_general", &["-g"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_exponents_positive_numeric() {
|
||||
test_helper("exponents-positive-numeric", "-n");
|
||||
test_helper(
|
||||
"exponents-positive-numeric",
|
||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_months_dedup() {
|
||||
test_helper("months-dedup", "-Mu");
|
||||
test_helper("months-dedup", &["-Mu"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mixed_floats_ints_chars_numeric() {
|
||||
test_helper("mixed_floats_ints_chars_numeric", "-n");
|
||||
test_helper(
|
||||
"mixed_floats_ints_chars_numeric",
|
||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mixed_floats_ints_chars_numeric_unique() {
|
||||
test_helper("mixed_floats_ints_chars_numeric_unique", "-nu");
|
||||
test_helper("mixed_floats_ints_chars_numeric_unique", &["-nu"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_words_unique() {
|
||||
test_helper("words_unique", "-u");
|
||||
test_helper("words_unique", &["-u"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_numeric_unique() {
|
||||
test_helper("numeric_unique", "-nu");
|
||||
test_helper("numeric_unique", &["-nu"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mixed_floats_ints_chars_numeric_reverse() {
|
||||
test_helper("mixed_floats_ints_chars_numeric_unique_reverse", "-nur");
|
||||
test_helper("mixed_floats_ints_chars_numeric_unique_reverse", &["-nur"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mixed_floats_ints_chars_numeric_stable() {
|
||||
test_helper("mixed_floats_ints_chars_numeric_stable", "-ns");
|
||||
test_helper("mixed_floats_ints_chars_numeric_stable", &["-ns"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -347,12 +385,15 @@ fn test_numeric_floats2() {
|
|||
|
||||
#[test]
|
||||
fn test_numeric_floats_with_nan2() {
|
||||
test_helper("numeric-floats-with-nan2", "-n");
|
||||
test_helper(
|
||||
"numeric-floats-with-nan2",
|
||||
&["-n", "--numeric-sort", "--sort=numeric"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_human_block_sizes2() {
|
||||
for human_numeric_sort_param in vec!["-h", "--human-numeric-sort"] {
|
||||
for human_numeric_sort_param in &["-h", "--human-numeric-sort", "--sort=human-numeric"] {
|
||||
let input = "8981K\n909991M\n-8T\n21G\n0.8M";
|
||||
new_ucmd!()
|
||||
.arg(human_numeric_sort_param)
|
||||
|
@ -364,7 +405,7 @@ fn test_human_block_sizes2() {
|
|||
|
||||
#[test]
|
||||
fn test_month_default2() {
|
||||
for month_sort_param in vec!["-M", "--month-sort"] {
|
||||
for month_sort_param in &["-M", "--month-sort", "--sort=month"] {
|
||||
let input = "JAn\nMAY\n000may\nJun\nFeb";
|
||||
new_ucmd!()
|
||||
.arg(month_sort_param)
|
||||
|
@ -397,32 +438,32 @@ fn test_numeric_unique_ints2() {
|
|||
|
||||
#[test]
|
||||
fn test_keys_open_ended() {
|
||||
test_helper("keys_open_ended", "-k 2.3");
|
||||
test_helper("keys_open_ended", &["-k 2.3"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_closed_range() {
|
||||
test_helper("keys_closed_range", "-k 2.2,2.2");
|
||||
test_helper("keys_closed_range", &["-k 2.2,2.2"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_multiple_ranges() {
|
||||
test_helper("keys_multiple_ranges", "-k 2,2 -k 3,3");
|
||||
test_helper("keys_multiple_ranges", &["-k 2,2 -k 3,3"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_no_field_match() {
|
||||
test_helper("keys_no_field_match", "-k 4,4");
|
||||
test_helper("keys_no_field_match", &["-k 4,4"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_no_char_match() {
|
||||
test_helper("keys_no_char_match", "-k 1.2");
|
||||
test_helper("keys_no_char_match", &["-k 1.2"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keys_custom_separator() {
|
||||
test_helper("keys_custom_separator", "-k 2.2,2.2 -t x");
|
||||
test_helper("keys_custom_separator", &["-k 2.2,2.2 -t x"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -534,7 +575,7 @@ aaaa
|
|||
|
||||
#[test]
|
||||
fn test_zero_terminated() {
|
||||
test_helper("zero-terminated", "-z");
|
||||
test_helper("zero-terminated", &["-z"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -27,12 +27,12 @@ fn test_stdbuf_line_buffered_stdout() {
|
|||
fn test_stdbuf_no_buffer_option_fails() {
|
||||
new_ucmd!().args(&["head"]).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",
|
||||
--error <MODE>\n \
|
||||
--input <MODE>\n \
|
||||
--output <MODE>\n\n\
|
||||
USAGE:\n \
|
||||
stdbuf OPTION... COMMAND\n\n\
|
||||
For more information try --help",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -349,7 +349,6 @@ fn test_sleep_interval() {
|
|||
new_ucmd!().arg("-s").arg("10").arg(FOOBAR_TXT).succeeds();
|
||||
}
|
||||
|
||||
|
||||
/// Test for reading all but the first NUM bytes: `tail -c +3`.
|
||||
#[test]
|
||||
fn test_positive_bytes() {
|
||||
|
@ -360,7 +359,6 @@ fn test_positive_bytes() {
|
|||
.stdout_is("cde");
|
||||
}
|
||||
|
||||
|
||||
/// Test for reading all bytes, specified by `tail -c +0`.
|
||||
#[test]
|
||||
fn test_positive_zero_bytes() {
|
||||
|
@ -371,7 +369,6 @@ fn test_positive_zero_bytes() {
|
|||
.stdout_is("abcde");
|
||||
}
|
||||
|
||||
|
||||
/// Test for reading all but the first NUM lines: `tail -n +3`.
|
||||
#[test]
|
||||
fn test_positive_lines() {
|
||||
|
@ -382,7 +379,6 @@ fn test_positive_lines() {
|
|||
.stdout_is("c\nd\ne\n");
|
||||
}
|
||||
|
||||
|
||||
/// Test for reading all lines, specified by `tail -n +0`.
|
||||
#[test]
|
||||
fn test_positive_zero_lines() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue