1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

Merge pull request #2338 from miDeb/ln/dst-symlink

ln: canonicalize the parent directory of the destination, not the destination itself
This commit is contained in:
Terts Diepraam 2021-06-12 11:28:19 +02:00 committed by GitHub
commit 440eba628c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 64 deletions

View file

@ -428,20 +428,6 @@ fn test_symlink_relative() {
assert_eq!(at.resolve_link(link), file_a);
}
#[test]
fn test_hardlink_relative() {
let (at, mut ucmd) = at_and_ucmd!();
let file_a = "test_hardlink_relative_a";
let link = "test_hardlink_relative_link";
at.touch(file_a);
// relative hardlink
ucmd.args(&["-r", "-v", file_a, link])
.succeeds()
.stdout_only(format!("'{}' -> '{}'\n", link, file_a));
}
#[test]
fn test_symlink_relative_path() {
let (at, mut ucmd) = at_and_ucmd!();
@ -571,3 +557,26 @@ fn test_symlink_no_deref_file() {
assert!(at.is_symlink(link));
assert_eq!(at.resolve_link(link), file1);
}
#[test]
fn test_relative_requires_symbolic() {
new_ucmd!().args(&["-r", "foo", "bar"]).fails();
}
#[test]
fn test_relative_dst_already_symlink() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("file1");
at.symlink_file("file1", "file2");
ucmd.arg("-srf").arg("file1").arg("file2").succeeds();
at.is_symlink("file2");
}
#[test]
fn test_relative_src_already_symlink() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("file1");
at.symlink_file("file1", "file2");
ucmd.arg("-sr").arg("file2").arg("file3").succeeds();
assert!(at.resolve_link("file3").ends_with("file1"));
}