1
Fork 0
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:
Jan Scheer 2022-06-02 16:31:25 +02:00
commit 8ee806a444
No known key found for this signature in database
GPG key ID: C62AD4C29E2B9828
16 changed files with 651 additions and 225 deletions

View file

@ -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);

View file

@ -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) {

View file

@ -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!()

View file

@ -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'");
}

View file

@ -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);
}

View file

@ -0,0 +1,148 @@
rs 0
di 01;34
ln 01;36
mh 00
pi 40;33
so 01;35
do 01;35
bd 40;33;01
cd 40;33;01
or 40;31;01
mi 00
su 37;41
sg 30;43
ca 00
tw 30;42
ow 34;42
st 37;44
ex 01;32
*.tar 01;31
*.tgz 01;31
*.arc 01;31
*.arj 01;31
*.taz 01;31
*.lha 01;31
*.lz4 01;31
*.lzh 01;31
*.lzma 01;31
*.tlz 01;31
*.txz 01;31
*.tzo 01;31
*.t7z 01;31
*.zip 01;31
*.z 01;31
*.dz 01;31
*.gz 01;31
*.lrz 01;31
*.lz 01;31
*.lzo 01;31
*.xz 01;31
*.zst 01;31
*.tzst 01;31
*.bz2 01;31
*.bz 01;31
*.tbz 01;31
*.tbz2 01;31
*.tz 01;31
*.deb 01;31
*.rpm 01;31
*.jar 01;31
*.war 01;31
*.ear 01;31
*.sar 01;31
*.rar 01;31
*.alz 01;31
*.ace 01;31
*.zoo 01;31
*.cpio 01;31
*.7z 01;31
*.rz 01;31
*.cab 01;31
*.wim 01;31
*.swm 01;31
*.dwm 01;31
*.esd 01;31
*.avif 01;35
*.jpg 01;35
*.jpeg 01;35
*.mjpg 01;35
*.mjpeg 01;35
*.gif 01;35
*.bmp 01;35
*.pbm 01;35
*.pgm 01;35
*.ppm 01;35
*.tga 01;35
*.xbm 01;35
*.xpm 01;35
*.tif 01;35
*.tiff 01;35
*.png 01;35
*.svg 01;35
*.svgz 01;35
*.mng 01;35
*.pcx 01;35
*.mov 01;35
*.mpg 01;35
*.mpeg 01;35
*.m2v 01;35
*.mkv 01;35
*.webm 01;35
*.webp 01;35
*.ogm 01;35
*.mp4 01;35
*.m4v 01;35
*.mp4v 01;35
*.vob 01;35
*.qt 01;35
*.nuv 01;35
*.wmv 01;35
*.asf 01;35
*.rm 01;35
*.rmvb 01;35
*.flc 01;35
*.avi 01;35
*.fli 01;35
*.flv 01;35
*.gl 01;35
*.dl 01;35
*.xcf 01;35
*.xwd 01;35
*.yuv 01;35
*.cgm 01;35
*.emf 01;35
*.ogv 01;35
*.ogx 01;35
*.aac 00;36
*.au 00;36
*.flac 00;36
*.m4a 00;36
*.mid 00;36
*.midi 00;36
*.mka 00;36
*.mp3 00;36
*.mpc 00;36
*.ogg 00;36
*.ra 00;36
*.wav 00;36
*.oga 00;36
*.opus 00;36
*.spx 00;36
*.xspf 00;36
*~ 00;90
*# 00;90
*.bak 00;90
*.old 00;90
*.orig 00;90
*.part 00;90
*.rej 00;90
*.swp 00;90
*.tmp 00;90
*.dpkg-dist 00;90
*.dpkg-old 00;90
*.ucf-dist 00;90
*.ucf-new 00;90
*.ucf-old 00;90
*.rpmnew 00;90
*.rpmorig 00;90
*.rpmsave 00;90