diff options
| author | Luke Kanies <luke@madstop.com> | 2005-07-20 18:04:54 +0000 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2005-07-20 18:04:54 +0000 |
| commit | bc38169686aa294c191382796ab3f9d6c4e96316 (patch) | |
| tree | c79576ecede46951f8991fed6b0d83bf522a0e79 /test | |
| parent | 973385f67a47b4dcc46da5022285025f3a7457ab (diff) | |
| download | puppet-bc38169686aa294c191382796ab3f9d6c4e96316.tar.gz puppet-bc38169686aa294c191382796ab3f9d6c4e96316.tar.xz puppet-bc38169686aa294c191382796ab3f9d6c4e96316.zip | |
redoing how arguments are handled in type.rb -- it is much cleaner now
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@430 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rw-r--r-- | test/types/tc_file.rb | 82 |
1 files changed, 57 insertions, 25 deletions
diff --git a/test/types/tc_file.rb b/test/types/tc_file.rb index 0eeab9bb9..ffb3b4f91 100644 --- a/test/types/tc_file.rb +++ b/test/types/tc_file.rb @@ -30,8 +30,10 @@ class TestFile < Test::Unit::TestCase def teardown Puppet::Type.allclear @@tmpfiles.each { |file| - system("chmod -R 755 %s" % file) - system("rm -rf %s" % file) + if FileTest.exists?(file) + system("chmod -R 755 %s" % file) + system("rm -rf %s" % file) + end } system("rm -f %s" % Puppet[:statefile]) end @@ -461,7 +463,32 @@ class TestFile < Test::Unit::TestCase } end - def test_complicatedlocalsource + def delete_random_files(dir) + checked = 0 + list = nil + FileUtils.cd(dir) { + list = %x{find . 2>/dev/null}.chomp.split(/\n/) + } + list.reverse.each_with_index { |file,i| + path = File.join(dir,file) + stat = File.stat(dir) + if checked < 10 and i % 3 == 0 + begin + if stat.ftype == "directory" + else + File.unlink(path) + end + rescue => detail + # we probably won't be able to open our own secured files + puts detail + next + end + checked += 1 + end + } + end + + def test_xcomplicatedlocalsource path = "/tmp/complsourcetest" @@tmpfiles.push path system("mkdir -p #{path}") @@ -473,33 +500,38 @@ class TestFile < Test::Unit::TestCase mkranddirsandfiles() } - todir = File.join(path,"todir") - tofile = nil - trans = nil + 2.times { + initstorage + todir = File.join(path,"todir") + tofile = nil + trans = nil - assert_nothing_raised { - tofile = Puppet::Type::PFile.new( - :name => todir, - "recurse" => true, - "source" => fromdir + assert_nothing_raised { + tofile = Puppet::Type::PFile.new( + :name => todir, + "recurse" => true, + "source" => fromdir + ) + } + comp = Puppet::Component.new( + :name => "component" ) + comp.push tofile + assert_nothing_raised { + trans = comp.evaluate + } + assert_nothing_raised { + trans.evaluate + } + assert_trees_equal(fromdir,todir) + clearstorage + Puppet::Type.allclear + delete_random_files(todir) } - comp = Puppet::Component.new( - :name => "component" - ) - comp.push tofile - assert_nothing_raised { - trans = comp.evaluate - } - assert_nothing_raised { - trans.evaluate - } - assert_trees_equal(fromdir,todir) - clearstorage - Puppet::Type.allclear + end - def test_xcopywithfailures + def test_copywithfailures path = "/tmp/failuresourcetest" @@tmpfiles.push path system("mkdir -p #{path}") |
