cp_r given a src ending in '/.' now copies over the contents of the

src dir.
This commit is contained in:
Jeff Hodges 2009-06-01 04:13:53 -07:00
parent da576d4208
commit c0be5bd8f2
2 changed files with 16 additions and 1 deletions

View File

@ -38,8 +38,14 @@ module FakeFS
raise Errno::ENOENT, dest raise Errno::ENOENT, dest
end end
# This last bit is a total abuse and should be thought hard
# about and cleaned up.
if new_dir if new_dir
new_dir[dir.name] = dir.entry.clone if src[-2..-1] == '/.'
dir.values.each{|f| new_dir[f.name] = f }
else
new_dir[dir.name] = dir.entry.clone
end
else else
FileSystem.add(dest, dir.entry.clone) FileSystem.add(dest, dir.entry.clone)
end end

View File

@ -354,6 +354,15 @@ class FakeFSTest < Test::Unit::TestCase
RealFile.unlink(here('foo')) if RealFile.exists?(here('foo')) RealFile.unlink(here('foo')) if RealFile.exists?(here('foo'))
end end
def test_putting_a_dot_at_end_copies_the_contents
FileUtils.mkdir_p 'subdir'
Dir.chdir('subdir'){ File.open('foo', 'w'){|f| f.write 'footext' } }
FileUtils.mkdir_p 'newdir'
FileUtils.cp_r 'subdir/.', 'newdir'
assert_equal 'footext', File.open('newdir/foo'){|f| f.read }
end
def test_file_can_read_from_symlinks def test_file_can_read_from_symlinks
File.open('first', 'w'){|f| f.write '1'} File.open('first', 'w'){|f| f.write '1'}
FileUtils.ln_s 'first', 'one' FileUtils.ln_s 'first', 'one'