mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-16 03:36:18 +00:00
Merge branch 'main' into tail_notify
This commit is contained in:
commit
8ee806a444
16 changed files with 651 additions and 225 deletions
|
@ -360,6 +360,47 @@ fn test_total() {
|
|||
assert_eq!(computed_total_avail, reported_total_avail);
|
||||
}
|
||||
|
||||
/// Test that the "total" label appears in the correct column.
|
||||
///
|
||||
/// The "total" label should appear in the "source" column, or in the
|
||||
/// "target" column if "source" is not visible.
|
||||
#[test]
|
||||
fn test_total_label_in_correct_column() {
|
||||
let output = new_ucmd!()
|
||||
.args(&["--output=source", "--total", "."])
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let last_line = output.lines().last().unwrap();
|
||||
assert_eq!(last_line.trim(), "total");
|
||||
|
||||
let output = new_ucmd!()
|
||||
.args(&["--output=target", "--total", "."])
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let last_line = output.lines().last().unwrap();
|
||||
assert_eq!(last_line.trim(), "total");
|
||||
|
||||
let output = new_ucmd!()
|
||||
.args(&["--output=source,target", "--total", "."])
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let last_line = output.lines().last().unwrap();
|
||||
assert_eq!(
|
||||
last_line.split_whitespace().collect::<Vec<&str>>(),
|
||||
vec!["total", "-"]
|
||||
);
|
||||
|
||||
let output = new_ucmd!()
|
||||
.args(&["--output=target,source", "--total", "."])
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let last_line = output.lines().last().unwrap();
|
||||
assert_eq!(
|
||||
last_line.split_whitespace().collect::<Vec<&str>>(),
|
||||
vec!["-", "total"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_use_percentage() {
|
||||
let output = new_ucmd!()
|
||||
|
@ -421,7 +462,7 @@ fn test_default_block_size() {
|
|||
.arg("--output=size")
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let header = output.lines().next().unwrap().to_string();
|
||||
let header = output.lines().next().unwrap().trim().to_string();
|
||||
|
||||
assert_eq!(header, "1K-blocks");
|
||||
|
||||
|
@ -430,7 +471,7 @@ fn test_default_block_size() {
|
|||
.env("POSIXLY_CORRECT", "1")
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let header = output.lines().next().unwrap().to_string();
|
||||
let header = output.lines().next().unwrap().trim().to_string();
|
||||
|
||||
assert_eq!(header, "512B-blocks");
|
||||
}
|
||||
|
@ -445,6 +486,7 @@ fn test_default_block_size_in_posix_portability_mode() {
|
|||
.split_whitespace()
|
||||
.nth(1)
|
||||
.unwrap()
|
||||
.trim()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
|
@ -466,7 +508,7 @@ fn test_block_size_1024() {
|
|||
.args(&["-B", &format!("{}", block_size), "--output=size"])
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
output.lines().next().unwrap().to_string()
|
||||
output.lines().next().unwrap().trim().to_string()
|
||||
}
|
||||
|
||||
assert_eq!(get_header(1024), "1K-blocks");
|
||||
|
@ -490,7 +532,7 @@ fn test_block_size_with_suffix() {
|
|||
.args(&["-B", block_size, "--output=size"])
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
output.lines().next().unwrap().to_string()
|
||||
output.lines().next().unwrap().trim().to_string()
|
||||
}
|
||||
|
||||
assert_eq!(get_header("K"), "1K-blocks");
|
||||
|
@ -522,6 +564,7 @@ fn test_block_size_in_posix_portability_mode() {
|
|||
.split_whitespace()
|
||||
.nth(1)
|
||||
.unwrap()
|
||||
.trim()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
|
@ -540,7 +583,7 @@ fn test_block_size_from_env() {
|
|||
.env(env_var, env_value)
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
output.lines().next().unwrap().to_string()
|
||||
output.lines().next().unwrap().trim().to_string()
|
||||
}
|
||||
|
||||
assert_eq!(get_header("DF_BLOCK_SIZE", "111"), "111B-blocks");
|
||||
|
@ -559,7 +602,7 @@ fn test_block_size_from_env_precedences() {
|
|||
.env(k2, v2)
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
output.lines().next().unwrap().to_string()
|
||||
output.lines().next().unwrap().trim().to_string()
|
||||
}
|
||||
|
||||
let df_block_size = ("DF_BLOCK_SIZE", "111");
|
||||
|
@ -578,7 +621,7 @@ fn test_precedence_of_block_size_arg_over_env() {
|
|||
.env("DF_BLOCK_SIZE", "111")
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let header = output.lines().next().unwrap().to_string();
|
||||
let header = output.lines().next().unwrap().trim().to_string();
|
||||
|
||||
assert_eq!(header, "999B-blocks");
|
||||
}
|
||||
|
@ -592,7 +635,7 @@ fn test_invalid_block_size_from_env() {
|
|||
.env("DF_BLOCK_SIZE", "invalid")
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let header = output.lines().next().unwrap().to_string();
|
||||
let header = output.lines().next().unwrap().trim().to_string();
|
||||
|
||||
assert_eq!(header, default_block_size_header);
|
||||
|
||||
|
@ -602,7 +645,7 @@ fn test_invalid_block_size_from_env() {
|
|||
.env("BLOCK_SIZE", "222")
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let header = output.lines().next().unwrap().to_string();
|
||||
let header = output.lines().next().unwrap().trim().to_string();
|
||||
|
||||
assert_eq!(header, default_block_size_header);
|
||||
}
|
||||
|
@ -626,6 +669,7 @@ fn test_ignore_block_size_from_env_in_posix_portability_mode() {
|
|||
.split_whitespace()
|
||||
.nth(1)
|
||||
.unwrap()
|
||||
.trim()
|
||||
.to_string();
|
||||
|
||||
assert_eq!(header, default_block_size_header);
|
||||
|
|
|
@ -62,6 +62,14 @@ fn test_internal_db() {
|
|||
.stdout_is_fixture("internal.expected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ls_colors() {
|
||||
new_ucmd!()
|
||||
.arg("--print-ls-colors")
|
||||
.run()
|
||||
.stdout_is_fixture("ls_colors.expected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bash_default() {
|
||||
new_ucmd!()
|
||||
|
@ -109,6 +117,18 @@ fn test_exclusive_option() {
|
|||
.arg("-cp")
|
||||
.fails()
|
||||
.stderr_contains("mutually exclusive");
|
||||
new_ucmd!()
|
||||
.args(&["-b", "--print-ls-colors"])
|
||||
.fails()
|
||||
.stderr_contains("mutually exclusive");
|
||||
new_ucmd!()
|
||||
.args(&["-c", "--print-ls-colors"])
|
||||
.fails()
|
||||
.stderr_contains("mutually exclusive");
|
||||
new_ucmd!()
|
||||
.args(&["-p", "--print-ls-colors"])
|
||||
.fails()
|
||||
.stderr_contains("mutually exclusive");
|
||||
}
|
||||
|
||||
fn test_helper(file_name: &str, term: &str) {
|
||||
|
|
|
@ -73,6 +73,15 @@ fn test_tabs_mixed_style_list() {
|
|||
.stdout_is("a b c d e");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multiple_tabs_args() {
|
||||
new_ucmd!()
|
||||
.args(&["--tabs=3", "--tabs=6", "--tabs=9"])
|
||||
.pipe_in("a\tb\tc\td\te")
|
||||
.succeeds()
|
||||
.stdout_is("a b c d e");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tabs_empty_string() {
|
||||
new_ucmd!()
|
||||
|
|
|
@ -650,3 +650,55 @@ fn test_backup_force() {
|
|||
// we should have the same content as b as we had time to do a backup
|
||||
assert_eq!(at.read("b~"), "b2\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hard_logical() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let file_a = "file1";
|
||||
let link = "symlink1";
|
||||
let target = "hard-to-a";
|
||||
let target2 = "hard-to-a2";
|
||||
at.touch(file_a);
|
||||
at.symlink_file(file_a, link);
|
||||
|
||||
ucmd.args(&["-P", "-L", link, target]);
|
||||
assert!(!at.is_symlink(target));
|
||||
|
||||
ucmd.args(&["-P", "-L", "-s", link, target2]);
|
||||
assert!(!at.is_symlink(target2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hard_logical_non_exit_fail() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let file_a = "/no-such-dir";
|
||||
let link = "hard-to-dangle";
|
||||
|
||||
scene.ucmd().args(&["-s", file_a]);
|
||||
assert!(!at.is_symlink("no-such-dir"));
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-L", "no-such-dir", link])
|
||||
.fails()
|
||||
.stderr_contains("failed to link 'no-such-dir'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hard_logical_dir_fail() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let dir = "d";
|
||||
at.mkdir(dir);
|
||||
let target = "link-to-dir";
|
||||
|
||||
scene.ucmd().args(&["-s", dir, target]);
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-L", target, "hard-to-dir-link"])
|
||||
.fails()
|
||||
.stderr_contains("failed to link 'link-to-dir'");
|
||||
}
|
||||
|
|
|
@ -519,6 +519,7 @@ fn test_directory_permissions() {
|
|||
/// Test that a template with a path separator is invalid.
|
||||
#[test]
|
||||
fn test_template_path_separator() {
|
||||
#[cfg(not(windows))]
|
||||
new_ucmd!()
|
||||
.args(&["-t", "a/bXXX"])
|
||||
.fails()
|
||||
|
@ -526,6 +527,14 @@ fn test_template_path_separator() {
|
|||
"mktemp: invalid template, {}, contains directory separator\n",
|
||||
"a/bXXX".quote()
|
||||
));
|
||||
#[cfg(windows)]
|
||||
new_ucmd!()
|
||||
.args(&["-t", r"a\bXXX"])
|
||||
.fails()
|
||||
.stderr_only(format!(
|
||||
"mktemp: invalid template, {}, contains directory separator\n",
|
||||
r"a\bXXX".quote()
|
||||
));
|
||||
}
|
||||
|
||||
/// Test that a suffix with a path separator is invalid.
|
||||
|
@ -558,3 +567,8 @@ fn test_too_few_xs_suffix_directory() {
|
|||
.fails()
|
||||
.stderr_only("mktemp: too few X's in template 'aXXX'\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_too_many_arguments() {
|
||||
new_ucmd!().args(&["-q", "a", "b"]).fails().code_is(1);
|
||||
}
|
||||
|
|
148
tests/fixtures/dircolors/ls_colors.expected
vendored
Normal file
148
tests/fixtures/dircolors/ls_colors.expected
vendored
Normal file
|
@ -0,0 +1,148 @@
|
|||
[0mrs 0[0m
|
||||
[01;34mdi 01;34[0m
|
||||
[01;36mln 01;36[0m
|
||||
[00mmh 00[0m
|
||||
[40;33mpi 40;33[0m
|
||||
[01;35mso 01;35[0m
|
||||
[01;35mdo 01;35[0m
|
||||
[40;33;01mbd 40;33;01[0m
|
||||
[40;33;01mcd 40;33;01[0m
|
||||
[40;31;01mor 40;31;01[0m
|
||||
[00mmi 00[0m
|
||||
[37;41msu 37;41[0m
|
||||
[30;43msg 30;43[0m
|
||||
[00mca 00[0m
|
||||
[30;42mtw 30;42[0m
|
||||
[34;42mow 34;42[0m
|
||||
[37;44mst 37;44[0m
|
||||
[01;32mex 01;32[0m
|
||||
[01;31m*.tar 01;31[0m
|
||||
[01;31m*.tgz 01;31[0m
|
||||
[01;31m*.arc 01;31[0m
|
||||
[01;31m*.arj 01;31[0m
|
||||
[01;31m*.taz 01;31[0m
|
||||
[01;31m*.lha 01;31[0m
|
||||
[01;31m*.lz4 01;31[0m
|
||||
[01;31m*.lzh 01;31[0m
|
||||
[01;31m*.lzma 01;31[0m
|
||||
[01;31m*.tlz 01;31[0m
|
||||
[01;31m*.txz 01;31[0m
|
||||
[01;31m*.tzo 01;31[0m
|
||||
[01;31m*.t7z 01;31[0m
|
||||
[01;31m*.zip 01;31[0m
|
||||
[01;31m*.z 01;31[0m
|
||||
[01;31m*.dz 01;31[0m
|
||||
[01;31m*.gz 01;31[0m
|
||||
[01;31m*.lrz 01;31[0m
|
||||
[01;31m*.lz 01;31[0m
|
||||
[01;31m*.lzo 01;31[0m
|
||||
[01;31m*.xz 01;31[0m
|
||||
[01;31m*.zst 01;31[0m
|
||||
[01;31m*.tzst 01;31[0m
|
||||
[01;31m*.bz2 01;31[0m
|
||||
[01;31m*.bz 01;31[0m
|
||||
[01;31m*.tbz 01;31[0m
|
||||
[01;31m*.tbz2 01;31[0m
|
||||
[01;31m*.tz 01;31[0m
|
||||
[01;31m*.deb 01;31[0m
|
||||
[01;31m*.rpm 01;31[0m
|
||||
[01;31m*.jar 01;31[0m
|
||||
[01;31m*.war 01;31[0m
|
||||
[01;31m*.ear 01;31[0m
|
||||
[01;31m*.sar 01;31[0m
|
||||
[01;31m*.rar 01;31[0m
|
||||
[01;31m*.alz 01;31[0m
|
||||
[01;31m*.ace 01;31[0m
|
||||
[01;31m*.zoo 01;31[0m
|
||||
[01;31m*.cpio 01;31[0m
|
||||
[01;31m*.7z 01;31[0m
|
||||
[01;31m*.rz 01;31[0m
|
||||
[01;31m*.cab 01;31[0m
|
||||
[01;31m*.wim 01;31[0m
|
||||
[01;31m*.swm 01;31[0m
|
||||
[01;31m*.dwm 01;31[0m
|
||||
[01;31m*.esd 01;31[0m
|
||||
[01;35m*.avif 01;35[0m
|
||||
[01;35m*.jpg 01;35[0m
|
||||
[01;35m*.jpeg 01;35[0m
|
||||
[01;35m*.mjpg 01;35[0m
|
||||
[01;35m*.mjpeg 01;35[0m
|
||||
[01;35m*.gif 01;35[0m
|
||||
[01;35m*.bmp 01;35[0m
|
||||
[01;35m*.pbm 01;35[0m
|
||||
[01;35m*.pgm 01;35[0m
|
||||
[01;35m*.ppm 01;35[0m
|
||||
[01;35m*.tga 01;35[0m
|
||||
[01;35m*.xbm 01;35[0m
|
||||
[01;35m*.xpm 01;35[0m
|
||||
[01;35m*.tif 01;35[0m
|
||||
[01;35m*.tiff 01;35[0m
|
||||
[01;35m*.png 01;35[0m
|
||||
[01;35m*.svg 01;35[0m
|
||||
[01;35m*.svgz 01;35[0m
|
||||
[01;35m*.mng 01;35[0m
|
||||
[01;35m*.pcx 01;35[0m
|
||||
[01;35m*.mov 01;35[0m
|
||||
[01;35m*.mpg 01;35[0m
|
||||
[01;35m*.mpeg 01;35[0m
|
||||
[01;35m*.m2v 01;35[0m
|
||||
[01;35m*.mkv 01;35[0m
|
||||
[01;35m*.webm 01;35[0m
|
||||
[01;35m*.webp 01;35[0m
|
||||
[01;35m*.ogm 01;35[0m
|
||||
[01;35m*.mp4 01;35[0m
|
||||
[01;35m*.m4v 01;35[0m
|
||||
[01;35m*.mp4v 01;35[0m
|
||||
[01;35m*.vob 01;35[0m
|
||||
[01;35m*.qt 01;35[0m
|
||||
[01;35m*.nuv 01;35[0m
|
||||
[01;35m*.wmv 01;35[0m
|
||||
[01;35m*.asf 01;35[0m
|
||||
[01;35m*.rm 01;35[0m
|
||||
[01;35m*.rmvb 01;35[0m
|
||||
[01;35m*.flc 01;35[0m
|
||||
[01;35m*.avi 01;35[0m
|
||||
[01;35m*.fli 01;35[0m
|
||||
[01;35m*.flv 01;35[0m
|
||||
[01;35m*.gl 01;35[0m
|
||||
[01;35m*.dl 01;35[0m
|
||||
[01;35m*.xcf 01;35[0m
|
||||
[01;35m*.xwd 01;35[0m
|
||||
[01;35m*.yuv 01;35[0m
|
||||
[01;35m*.cgm 01;35[0m
|
||||
[01;35m*.emf 01;35[0m
|
||||
[01;35m*.ogv 01;35[0m
|
||||
[01;35m*.ogx 01;35[0m
|
||||
[00;36m*.aac 00;36[0m
|
||||
[00;36m*.au 00;36[0m
|
||||
[00;36m*.flac 00;36[0m
|
||||
[00;36m*.m4a 00;36[0m
|
||||
[00;36m*.mid 00;36[0m
|
||||
[00;36m*.midi 00;36[0m
|
||||
[00;36m*.mka 00;36[0m
|
||||
[00;36m*.mp3 00;36[0m
|
||||
[00;36m*.mpc 00;36[0m
|
||||
[00;36m*.ogg 00;36[0m
|
||||
[00;36m*.ra 00;36[0m
|
||||
[00;36m*.wav 00;36[0m
|
||||
[00;36m*.oga 00;36[0m
|
||||
[00;36m*.opus 00;36[0m
|
||||
[00;36m*.spx 00;36[0m
|
||||
[00;36m*.xspf 00;36[0m
|
||||
[00;90m*~ 00;90[0m
|
||||
[00;90m*# 00;90[0m
|
||||
[00;90m*.bak 00;90[0m
|
||||
[00;90m*.old 00;90[0m
|
||||
[00;90m*.orig 00;90[0m
|
||||
[00;90m*.part 00;90[0m
|
||||
[00;90m*.rej 00;90[0m
|
||||
[00;90m*.swp 00;90[0m
|
||||
[00;90m*.tmp 00;90[0m
|
||||
[00;90m*.dpkg-dist 00;90[0m
|
||||
[00;90m*.dpkg-old 00;90[0m
|
||||
[00;90m*.ucf-dist 00;90[0m
|
||||
[00;90m*.ucf-new 00;90[0m
|
||||
[00;90m*.ucf-old 00;90[0m
|
||||
[00;90m*.rpmnew 00;90[0m
|
||||
[00;90m*.rpmorig 00;90[0m
|
||||
[00;90m*.rpmsave 00;90[0m
|
Loading…
Add table
Add a link
Reference in a new issue