diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-11-24 15:58:07 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-11-24 15:58:07 +0000 |
| commit | 5ce5b95af489685f64dbaa6189f7569e976e9dc5 (patch) | |
| tree | 370d6d0510d32f4742377b11b0e070cdb103b887 | |
| parent | 84bf2896a80bc527f345e49ffb8fb1b5817fdfe6 (diff) | |
| download | puppet-5ce5b95af489685f64dbaa6189f7569e976e9dc5.tar.gz puppet-5ce5b95af489685f64dbaa6189f7569e976e9dc5.tar.xz puppet-5ce5b95af489685f64dbaa6189f7569e976e9dc5.zip | |
removing any direct references to /tmp in tests
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@757 980ebf18-57e1-0310-9a29-db15c13687c0
| -rw-r--r-- | test/client/client.rb | 2 | ||||
| -rwxr-xr-x | test/executables/puppetbin.rb | 2 | ||||
| -rwxr-xr-x | test/executables/puppetca.rb | 2 | ||||
| -rwxr-xr-x | test/executables/puppetmodule.rb | 1 | ||||
| -rwxr-xr-x | test/other/events.rb | 15 | ||||
| -rw-r--r-- | test/other/log.rb | 10 | ||||
| -rw-r--r-- | test/other/state.rb | 21 | ||||
| -rw-r--r-- | test/parser/parser.rb | 3 | ||||
| -rwxr-xr-x | test/server/fileserver.rb | 6 | ||||
| -rwxr-xr-x | test/types/component.rb | 6 | ||||
| -rwxr-xr-x | test/types/exec.rb | 2 | ||||
| -rw-r--r-- | test/types/file.rb | 2 | ||||
| -rw-r--r-- | test/types/fileignoresource.rb | 9 | ||||
| -rwxr-xr-x | test/types/filesources.rb | 14 | ||||
| -rw-r--r-- | test/types/filetype.rb | 11 | ||||
| -rw-r--r-- | test/types/package.rb | 8 |
16 files changed, 46 insertions, 68 deletions
diff --git a/test/client/client.rb b/test/client/client.rb index 39c19bb16..608fa1dc6 100644 --- a/test/client/client.rb +++ b/test/client/client.rb @@ -138,7 +138,7 @@ class TestClient < Test::Unit::TestCase # i don't think this test makes much sense anyway def disabled_test_sslInitWithNonsigningLocalServer Puppet[:autosign] = false - Puppet[:ssldir] = "/tmp/puppetclientcertests" + Puppet[:ssldir] = tempfile() @@tmpfiles.push Puppet[:ssldir] file = File.join($puppetbase, "examples", "code", "head") diff --git a/test/executables/puppetbin.rb b/test/executables/puppetbin.rb index 4c1d2a24c..d075d8431 100755 --- a/test/executables/puppetbin.rb +++ b/test/executables/puppetbin.rb @@ -31,7 +31,7 @@ class TestPuppetBin < Test::Unit::TestCase def test_execution file = mktestmanifest() - @@tmpfiles << "/tmp/puppetbintesting" + @@tmpfiles << tempfile() output = nil cmd = "puppet" diff --git a/test/executables/puppetca.rb b/test/executables/puppetca.rb index 2fed58557..819ecf702 100755 --- a/test/executables/puppetca.rb +++ b/test/executables/puppetca.rb @@ -37,7 +37,7 @@ class TestPuppetCA < Test::Unit::TestCase def test_signing ca = nil - Puppet[:ssldir] = "/tmp/puppetcatest" + Puppet[:ssldir] = tempfile() @@tmpfiles << Puppet[:ssldir] Puppet[:autosign] = false assert_nothing_raised { diff --git a/test/executables/puppetmodule.rb b/test/executables/puppetmodule.rb index ba356f6cc..2e97a963a 100755 --- a/test/executables/puppetmodule.rb +++ b/test/executables/puppetmodule.rb @@ -47,7 +47,6 @@ class TestPuppetModule < Test::Unit::TestCase ENV["CFALLCLASSES"] = "yaytest:all" - Puppet.err :mark assert_nothing_raised { system(cmd + " " + file) } diff --git a/test/other/events.rb b/test/other/events.rb index 61551983e..f295608f1 100755 --- a/test/other/events.rb +++ b/test/other/events.rb @@ -18,8 +18,9 @@ class TestEvents < Test::Unit::TestCase end def test_simplesubscribe + name = tempfile() file = Puppet::Type::PFile.create( - :name => "/tmp/eventtestingA", + :name => name, :create => true ) exec = Puppet::Type::Exec.create( @@ -29,8 +30,6 @@ class TestEvents < Test::Unit::TestCase :subscribe => [[file.class.name, file.name]] ) - @@tmpfiles << "/tmp/eventtestingA" - comp = newcomp("eventtesting", file, exec) trans = assert_events(comp, [:file_created], "events") @@ -39,8 +38,9 @@ class TestEvents < Test::Unit::TestCase end def test_simplerequire + name = tempfile() file = Puppet::Type::PFile.create( - :name => "/tmp/eventtestingA", + :name => name, :create => true ) exec = Puppet::Type::Exec.create( @@ -50,7 +50,6 @@ class TestEvents < Test::Unit::TestCase :require => [[file.class.name, file.name]] ) - @@tmpfiles << "/tmp/eventtestingA" comp = Puppet::Type::Component.create( :name => "eventtesting" @@ -67,14 +66,14 @@ class TestEvents < Test::Unit::TestCase assert_equal(0, trans.triggered?(exec, :refresh)) end - def test_zladderrequire + def test_ladderrequire comps = {} objects = {} - fname = "/tmp/eventtestfuntest" + fname = tempfile() [:a, :b].each { |l| case l when :a - name = "/tmp/eventtesting%s" % l + name = tempfile() + l.to_s objects[l] = Puppet::Type::PFile.create( :name => name, :create => true diff --git a/test/other/log.rb b/test/other/log.rb index 764a3c83f..f082be6ad 100644 --- a/test/other/log.rb +++ b/test/other/log.rb @@ -109,12 +109,12 @@ class TestLog < Test::Unit::TestCase end def test_creatingdirs - Puppet[:logdest] = "/tmp/logtesting/logfile" + dir = tempfile() + file = File.join(dir, "logfile") + Puppet[:logdest] = file Puppet.info "testing logs" - assert(FileTest.directory?("/tmp/logtesting")) - assert(FileTest.file?("/tmp/logtesting/logfile")) - - system("rm -rf /tmp/logtesting") + assert(FileTest.directory?(dir)) + assert(FileTest.file?(file)) end def test_logtags diff --git a/test/other/state.rb b/test/other/state.rb index bd17d86c3..c53829311 100644 --- a/test/other/state.rb +++ b/test/other/state.rb @@ -16,27 +16,6 @@ end class TestStorage < Test::Unit::TestCase include TestPuppet - def disabled_setup - Puppet[:loglevel] = :debug if __FILE__ == $0 - Puppet[:checksumfile] = "/var/tmp/puppetteststate" - - @oldconf = Puppet[:puppetconf] - Puppet[:puppetconf] = "/tmp/storagetesting" - @oldvar = Puppet[:puppetvar] - Puppet[:puppetvar] = "/tmp/storagetesting" - - @@tmpfiles << "/tmp/storagetesting" - end - - def teardown - #system("rm -f %s" % Puppet[:checksumfile]) - Puppet::Storage.clear - - #Puppet[:puppetconf] = @oldconf - #Puppet[:puppetvar] = @oldvar - super - end - def test_simple state = nil assert_nothing_raised { diff --git a/test/parser/parser.rb b/test/parser/parser.rb index 16ac0048b..4752ce35e 100644 --- a/test/parser/parser.rb +++ b/test/parser/parser.rb @@ -51,8 +51,9 @@ class TestParser < Test::Unit::TestCase def test_arrayrvalues parser = Puppet::Parser::Parser.new() ret = nil + file = tempfile() assert_nothing_raised { - parser.string = 'file { "/tmp/testing": mode => [755, 640] }' + parser.string = "file { \"#{file}\": mode => [755, 640] }" } assert_nothing_raised { diff --git a/test/server/fileserver.rb b/test/server/fileserver.rb index f6037f17d..98c0c4cb4 100755 --- a/test/server/fileserver.rb +++ b/test/server/fileserver.rb @@ -317,7 +317,7 @@ class TestFileServer < Test::Unit::TestCase # create a deep dir - basedir = "/tmp/remotefilecopying" + basedir = tempfile() testdir = "%s/with/some/sub/directories/for/testing" % basedir oldfile = File.join(testdir, "oldfile") assert_nothing_raised { @@ -358,7 +358,7 @@ class TestFileServer < Test::Unit::TestCase ) } - basedir = "/tmp/remotefilecopying" + basedir = tempfile() dirs = %w{a set of directories} assert_nothing_raised { Dir.mkdir(basedir) @@ -385,7 +385,7 @@ class TestFileServer < Test::Unit::TestCase # verify that 'describe' works as advertised def test_describe server = nil - testdir = "/tmp/remotefilecopying" + testdir = tempfile() files = mktestfiles(testdir) file = nil diff --git a/test/types/component.rb b/test/types/component.rb index ea1c797ac..7243ed2fc 100755 --- a/test/types/component.rb +++ b/test/types/component.rb @@ -40,7 +40,7 @@ class TestComponent < Test::Unit::TestCase unless num num = randnum(1000) end - name = "/tmp/componentrandfile" + num.to_s + name = tempfile() + num.to_s file = Puppet::Type::PFile.create( :path => name, @@ -107,7 +107,7 @@ class TestComponent < Test::Unit::TestCase end def test_correctsorting - tmpfile = "/tmp/comptesting" + tmpfile = tempfile() @@tmpfiles.push tmpfile trans = nil cmd = nil @@ -138,7 +138,7 @@ class TestComponent < Test::Unit::TestCase end def test_correctflattening - tmpfile = "/tmp/comptesting" + tmpfile = tempfile() @@tmpfiles.push tmpfile trans = nil cmd = nil diff --git a/test/types/exec.rb b/test/types/exec.rb index bbe1ba3b6..2da818755 100755 --- a/test/types/exec.rb +++ b/test/types/exec.rb @@ -141,7 +141,7 @@ class TestExec < Test::Unit::TestCase def test_refreshonly file = nil cmd = nil - tmpfile = "/tmp/exectesting" + tmpfile = tempfile() @@tmpfiles.push tmpfile trans = nil File.open(tmpfile, File::WRONLY|File::CREAT|File::TRUNC) { |of| diff --git a/test/types/file.rb b/test/types/file.rb index 420c0bbcf..f01440903 100644 --- a/test/types/file.rb +++ b/test/types/file.rb @@ -231,7 +231,7 @@ class TestFile < Test::Unit::TestCase end def test_create - %w{a b c d}.collect { |name| "/tmp/createst%s" % name }.each { |path| + %w{a b c d}.collect { |name| tempfile() + name.to_s }.each { |path| file =nil assert_nothing_raised() { file = Puppet::Type::PFile.create( diff --git a/test/types/fileignoresource.rb b/test/types/fileignoresource.rb index ca89803d1..747fbcfed 100644 --- a/test/types/fileignoresource.rb +++ b/test/types/fileignoresource.rb @@ -11,7 +11,6 @@ require 'test/unit' require 'fileutils' require 'puppettest' -# $Id: $ class TestFileIgnoreSources < Test::Unit::TestCase include FileTesting @@ -44,7 +43,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase def test_ignore_simple_source #Temp directory to run tests in - path = "/tmp/Fileignoresourcetest" + path = tempfile() @@tmpfiles.push path #source directory @@ -113,7 +112,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase def test_ignore_with_wildcard #Temp directory to run tests in - path = "/tmp/Fileignoresourcetest" + path = tempfile() @@tmpfiles.push path #source directory @@ -192,7 +191,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase def test_ignore_array #Temp directory to run tests in - path = "/tmp/Fileignoresourcetest" + path = tempfile() @@tmpfiles.push path #source directory @@ -285,3 +284,5 @@ class TestFileIgnoreSources < Test::Unit::TestCase end end + +# $Id$ diff --git a/test/types/filesources.rb b/test/types/filesources.rb index 45cfd3784..b6c8c1b3c 100755 --- a/test/types/filesources.rb +++ b/test/types/filesources.rb @@ -43,7 +43,7 @@ class TestFileSources < Test::Unit::TestCase end def test_newchild - path = "/tmp/newchilddir" + path = tempfile() @@tmpfiles.push path FileUtils.mkdir_p path @@ -69,7 +69,7 @@ class TestFileSources < Test::Unit::TestCase end def test_simplelocalsource - path = "/tmp/Filesourcetest" + path = tempfile() @@tmpfiles.push path FileUtils.mkdir_p path frompath = File.join(path,"source") @@ -138,7 +138,7 @@ class TestFileSources < Test::Unit::TestCase end def run_complex_sources(networked = false) - path = "/tmp/ComplexSourcesTest" + path = tempfile() @@tmpfiles.push path # first create the source directory @@ -236,7 +236,7 @@ class TestFileSources < Test::Unit::TestCase end def test_RecursionWithAddedFiles - basedir = "/tmp/recursionplussaddedfiles" + basedir = tempfile() Dir.mkdir(basedir) @@tmpfiles << basedir file1 = File.join(basedir, "file1") @@ -277,7 +277,7 @@ class TestFileSources < Test::Unit::TestCase end def mkfileserverconf(mounts) - file = "/tmp/fileserverconftestingfile%s" % rand(100) + file = tempfile() File.open(file, "w") { |f| mounts.each { |path, name| f.puts "[#{name}]\n\tpath #{path}\n\tallow *\n" @@ -293,7 +293,7 @@ class TestFileSources < Test::Unit::TestCase # the certificates correct def disabled_test_SimpleNetworkSources server = nil - basedir = "/tmp/simplenetworksourcetesting" + basedir = tempfile() @@tmpfiles << basedir mounts = { @@ -375,7 +375,7 @@ class TestFileSources < Test::Unit::TestCase def test_NetworkSources server = nil - basedir = "/tmp/networksourcetesting" + basedir = tempfile() @@tmpfiles << basedir if File.exists?(basedir) system("rm -rf %s" % basedir) diff --git a/test/types/filetype.rb b/test/types/filetype.rb index c6749ba3d..faaf99478 100644 --- a/test/types/filetype.rb +++ b/test/types/filetype.rb @@ -9,8 +9,6 @@ require 'puppet/type/typegen/filetype' require 'puppet/type/typegen/filerecord' require 'test/unit' -# $Id$ - #class TestFileType < Test::Unit::TestCase class TestFileType def disabled_setup @@ -89,9 +87,10 @@ class TestFileType def disabled_test_passwd2_change file = nil type = nil - Kernel.system("cp /etc/passwd /tmp/oparsepasswd") + newfile = tempfile() + Kernel.system("cp /etc/passwd #{newfile}") assert_nothing_raised() { - file = @passwdtype.new("/tmp/oparsepasswd") + file = @passwdtype.new(newfile) } assert_nothing_raised() { file.retrieve @@ -130,8 +129,6 @@ class TestFileType } assert(file.insync?) - - Kernel.system("rm /tmp/oparsepasswd") end def disabled_test_syslog_nochange @@ -160,3 +157,5 @@ class TestFileType end end + +# $Id$ diff --git a/test/types/package.rb b/test/types/package.rb index 69fb16d5e..c5f781859 100644 --- a/test/types/package.rb +++ b/test/types/package.rb @@ -18,12 +18,12 @@ else class TestPackageSource < Test::Unit::TestCase include TestPuppet def test_filesource - system("touch /tmp/fakepackage") + path = tempfile() + system("touch %s" % path) assert_equal( - "/tmp/fakepackage", - Puppet::PackageSource.get("file:///tmp/fakepackage") + path, + Puppet::PackageSource.get("file://#{path}") ) - system("rm -f /tmp/fakepackage") end end |
