[ruby/fileutils] Just the parent path of the destination symlink should exist

71225b1b46
This commit is contained in:
Nobuyoshi Nakada 2025-07-19 23:04:54 +09:00 committed by git
parent 4431ca5363
commit 5a8e87cb2e
2 changed files with 6 additions and 2 deletions

View file

@ -739,7 +739,7 @@ module FileUtils
real_ddirs = fu_split_path(File.realpath(parent))
else
destdirs ||= fu_split_path(dest)
real_ddirs ||= fu_split_path(File.realpath(dest))
real_ddirs ||= fu_split_path(File.realdirpath(dest))
end
srcdirs = fu_split_path(s)
i = fu_common_components(srcdirs, destdirs)

View file

@ -1080,7 +1080,11 @@ class TestFileUtils < Test::Unit::TestCase
assert_raise(Errno::EEXIST, Errno::EACCES) {
ln_sr fname, 'tmp', target_directory: false
}
assert_file.not_exist? File.join('tmp/', File.basename(fname))
dest = File.join('tmp/', File.basename(fname))
assert_file.not_exist? dest
ln_sr fname, dest, target_directory: false
assert_file.symlink?(dest)
assert_equal("../#{fname}", File.readlink(dest))
end
end if have_symlink?