mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
ls: add already listed message (#3707)
* ls: handle looping symlinks infinite printing * ls: better coloring and printing symlinks when dereferenced * tests/ls: add dereferencing and symlink loop tests * ls: reformat changed using rustfmt * ls: follow clippy advice for cleaner code * uucore/fs: fix FileInformation to open directory handles in Windows as well
This commit is contained in:
parent
8f4a3266a4
commit
da5808d4ac
3 changed files with 122 additions and 18 deletions
|
@ -3065,3 +3065,62 @@ fn test_ls_quoting_color() {
|
|||
.succeeds()
|
||||
.stdout_contains("\'need quoting\'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ls_dereference_looped_symlinks_recursive() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.mkdir("loop");
|
||||
at.relative_symlink_dir("../loop", "loop/sub");
|
||||
|
||||
ucmd.args(&["-RL", "loop"])
|
||||
.fails()
|
||||
.stderr_contains("not listing already-listed directory");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dereference_dangling_color() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.relative_symlink_file("wat", "nonexistent");
|
||||
let out_exp = ucmd.args(&["--color"]).run().stdout_move_str();
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.relative_symlink_file("wat", "nonexistent");
|
||||
ucmd.args(&["-L", "--color"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains("No such file or directory")
|
||||
.stdout_is(out_exp);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dereference_symlink_dir_color() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.mkdir("dir1");
|
||||
at.mkdir("dir1/link");
|
||||
let out_exp = ucmd.args(&["--color", "dir1"]).run().stdout_move_str();
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.mkdir("dir1");
|
||||
at.mkdir("dir2");
|
||||
at.relative_symlink_dir("../dir2", "dir1/link");
|
||||
ucmd.args(&["-L", "--color", "dir1"])
|
||||
.succeeds()
|
||||
.stdout_is(out_exp);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dereference_symlink_file_color() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.mkdir("dir1");
|
||||
at.touch("dir1/link");
|
||||
let out_exp = ucmd.args(&["--color", "dir1"]).run().stdout_move_str();
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.mkdir("dir1");
|
||||
at.touch("file");
|
||||
at.relative_symlink_file("../file", "dir1/link");
|
||||
ucmd.args(&["-L", "--color", "dir1"])
|
||||
.succeeds()
|
||||
.stdout_is(out_exp);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue