summaryrefslogtreecommitdiff
path: root/test/fileutils/test_fileutils.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-20 07:03:11 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-20 07:03:11 +0000
commit0242f7ccae800eab5c3ab5f3129b1126ffbb45c3 (patch)
treeeac77c0e9180659eb96f11e3eeba9b0a99e5fe49 /test/fileutils/test_fileutils.rb
parent418771316cc54e9507287c563698519fb683c612 (diff)
Overwrite destination symlink file if `remove_destination` is set.
[Bug #13914][ruby-core:82846] Patch by @mzp https://github.com/ruby/fileutils/pull/9 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/fileutils/test_fileutils.rb')
-rw-r--r--test/fileutils/test_fileutils.rb21
1 files changed, 19 insertions, 2 deletions
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb
index bc659c2a0a..1efc371c55 100644
--- a/test/fileutils/test_fileutils.rb
+++ b/test/fileutils/test_fileutils.rb
@@ -12,7 +12,7 @@ class TestFileUtils < Test::Unit::TestCase
include Test::Unit::FileAssertions
def assert_output_lines(expected, fu = self, message=nil)
- old = fu.instance_variable_get(:@fileutils_output)
+ old = fu.instance_variables.include?(:@fileutils_output) && fu.instance_variable_get(:@fileutils_output)
IO.pipe {|read, write|
fu.instance_variable_set(:@fileutils_output, write)
th = Thread.new { read.read }
@@ -438,6 +438,15 @@ class TestFileUtils < Test::Unit::TestCase
}
end
+ def test_cp_r_symlink_remove_destination
+ Dir.mkdir 'tmp/src'
+ Dir.mkdir 'tmp/dest'
+ Dir.mkdir 'tmp/src/dir'
+ File.symlink 'tmp/src/dir', 'tmp/src/a'
+ cp_r 'tmp/src', 'tmp/dest/', remove_destination: true
+ cp_r 'tmp/src', 'tmp/dest/', remove_destination: true
+ end
+
def test_mv
check_singleton :mv
@@ -1401,7 +1410,7 @@ class TestFileUtils < Test::Unit::TestCase
def test_chown_R_without_permission
touch 'tmp/a'
- exception = assert_raise(Errno::EPERM) {
+ assert_raise(Errno::EPERM) {
chown_R UID_1, nil, 'tmp/a'
chown_R UID_2, nil, 'tmp/a'
}
@@ -1438,6 +1447,14 @@ class TestFileUtils < Test::Unit::TestCase
assert_equal 'somewhere', File.readlink('tmp/dirdest/sym')
end if have_symlink?
+ def test_copy_entry_symlink_remove_destination
+ Dir.mkdir 'tmp/dir'
+ File.symlink 'tmp/dir', 'tmp/dest'
+ touch 'tmp/src'
+ copy_entry 'tmp/src', 'tmp/dest', false, false, true
+ assert_file_exist 'tmp/dest'
+ end
+
def test_copy_file
check_singleton :copy_file