1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 21:47:46 +00:00

Merge pull request #2441 from siebenHeaven/ls_dangling_symlinks

ls: Fix problems dealing with dangling symlinks
This commit is contained in:
Sylvestre Ledru 2021-06-21 22:34:15 +02:00 committed by GitHub
commit e48ff9dd9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 6 deletions

View file

@ -2021,3 +2021,28 @@ fn test_ls_path() {
.run()
.stdout_is(expected_stdout);
}
#[test]
fn test_ls_dangling_symlinks() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.mkdir("temp_dir");
at.symlink_file("does_not_exist", "temp_dir/dangle");
scene.ucmd().arg("-L").arg("temp_dir/dangle").fails();
scene.ucmd().arg("-H").arg("temp_dir/dangle").fails();
scene
.ucmd()
.arg("temp_dir/dangle")
.succeeds()
.stdout_contains("dangle");
scene
.ucmd()
.arg("-Li")
.arg("temp_dir")
.succeeds() // this should fail, though at the moment, ls lacks a way to propagate errors encountered during display
.stdout_contains(if cfg!(windows) { "dangle" } else { "? dangle" });
}