From 6a6da71403269df83ef41b3d68ccd67c79230656 Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Fri, 3 Sep 2021 14:56:35 +0200 Subject: [PATCH] cp: add a test for #2631 --- tests/by-util/test_cp.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index c77f4c01d..08a9643ca 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -7,6 +7,8 @@ use std::fs::set_permissions; #[cfg(not(windows))] use std::os::unix::fs; +#[cfg(unix)] +use std::os::unix::fs::symlink as symlink_file; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; #[cfg(windows)] @@ -1353,3 +1355,16 @@ fn test_preserve_mode() { PERMS_ALL ); } + +#[test] +fn test_canonicalize_symlink() { + let (at, mut ucmd) = at_and_ucmd!(); + at.mkdir("dir"); + at.touch("dir/file"); + symlink_file("../dir/file", at.plus("dir/file-ln")).unwrap(); + ucmd.arg("dir/file-ln") + .arg(".") + .succeeds() + .no_stderr() + .no_stdout(); +}