we can now clone even hard to find dotfiles

This commit is contained in:
Jeff Hodges 2009-06-02 00:16:19 -07:00
parent 364dc66ee5
commit 8aba1ad6a5
2 changed files with 5 additions and 4 deletions

View File

@ -231,8 +231,7 @@ module FakeFS
def clone(path) def clone(path)
path = File.expand_path(path) path = File.expand_path(path)
pattern = File.join(path, '**', '*') pattern = File.join(path, '**', '*')
dot_pattern = File.join(path, '**', '.*') files = RealFile.file?(path) ? [path] : [path] + RealDir.glob(pattern, RealFile::FNM_DOTMATCH)
files = RealFile.file?(path) ? [path] : [path] + RealDir.glob([pattern, dot_pattern])
files.each do |f| files.each do |f|
if RealFile.file?(f) if RealFile.file?(f)

View File

@ -364,11 +364,13 @@ class FakeFSTest < Test::Unit::TestCase
RealFileUtils.rm_rf(here('subdir')) if RealFile.exists?(here('subdir')) RealFileUtils.rm_rf(here('subdir')) if RealFile.exists?(here('subdir'))
end end
def test_clone_clones_dot_files def test_clone_clones_dot_files_even_hard_to_find_ones
RealFileUtils.mkdir_p(here('subdir/.bar')) RealFileUtils.mkdir_p(here('subdir/.bar/baz/.quux/foo'))
assert !File.exists?(here('subdir')) assert !File.exists?(here('subdir'))
FileSystem.clone(here('subdir')) FileSystem.clone(here('subdir'))
assert_equal ['.bar'], FileSystem.find(here('subdir')).keys assert_equal ['.bar'], FileSystem.find(here('subdir')).keys
assert_equal ['foo'], FileSystem.find(here('subdir/.bar/baz/.quux')).keys
ensure ensure
RealFileUtils.rm_rf(here('subdir')) if RealFile.exists?(here('subdir')) RealFileUtils.rm_rf(here('subdir')) if RealFile.exists?(here('subdir'))
end end