diff --git a/test/language/parser.rb b/test/language/parser.rb index f7e636add..89bc7efe2 100755 --- a/test/language/parser.rb +++ b/test/language/parser.rb @@ -444,6 +444,7 @@ file { "/tmp/yayness": end tests.each do |form| + Puppet::Node::Environment.clear parser = mkparser if form == :virtual diff --git a/test/language/scope.rb b/test/language/scope.rb index ccc359651..ba053c36a 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -20,11 +20,6 @@ class TestScope < Test::Unit::TestCase include PuppetTest::ParserTesting include PuppetTest::ResourceTesting - def setup - Puppet::Node::Environment.clear - super - end - def to_ary(hash) hash.collect { |key,value| [key,value] diff --git a/test/language/snippets.rb b/test/language/snippets.rb index f34e3684e..d7d50701e 100755 --- a/test/language/snippets.rb +++ b/test/language/snippets.rb @@ -476,12 +476,11 @@ class TestSnippets < Test::Unit::TestCase Dir.entries(snippetdir).sort.each { |file| next if file =~ /^\./ - mname = "snippet_" + file.sub(/\.pp$/, '') if self.method_defined?(mname) #eval("alias #{testname} #{mname}") testname = ("test_#{mname}").intern - self.send(:define_method, testname) { + define_method(testname) { Puppet[:manifest] = snippet(file) facts = { "hostname" => "testhost", diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index 6bae80a01..76a967a5e 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -22,6 +22,8 @@ end require File.expand_path(File.join(File.dirname(__FILE__), '../../spec/monkey_patches/publicize_methods')) +require 'puppet/test/test_helper' + module PuppetTest # These need to be here for when rspec tests use these # support methods. @@ -145,6 +147,8 @@ module PuppetTest end def setup + Puppet::Test::TestHelper.before_each_test + ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin" unless ENV["PATH"].split(File::PATH_SEPARATOR).include?("/usr/sbin") @memoryatstart = Puppet::Util.memory if defined?(@@testcount) @@ -153,10 +157,8 @@ module PuppetTest @@testcount = 0 end - - @configpath = File.join( - tmpdir, - + @configpath = File.join( + tmpdir, "configdir" + @@testcount.to_s + "/" ) @@ -165,7 +167,6 @@ module PuppetTest $group = nonrootgroup.gid.to_s end - Puppet.settings.clear Puppet[:user] = $user Puppet[:group] = $group @@ -181,30 +182,16 @@ module PuppetTest @logs = [] - # If we're running under rake, then disable debugging and such. - #if rake? or ! Puppet[:debug] - #if defined?($puppet_debug) or ! rake? - Puppet[:color] = false if textmate? - Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs)) - if defined? $console - Puppet.info @method_name - Puppet::Util::Log.newdestination(:console) - Puppet[:trace] = true - end - Puppet::Util::Log.level = :debug - #$VERBOSE = 1 - #else - # Puppet::Util::Log.close - # Puppet::Util::Log.newdestination(@logs) - # Puppet[:httplog] = tempfile - #end + Puppet[:color] = false if textmate? + Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs)) + if defined? $console + Puppet.info @method_name + Puppet::Util::Log.newdestination(:console) + Puppet[:trace] = true + end + Puppet::Util::Log.level = :debug Puppet[:ignoreschedules] = true - - #@start = Time.now - - #Facter.stubs(:value).returns "stubbed_value" - #Facter.stubs(:to_hash).returns({}) end def tempfile(suffix = '') @@ -300,6 +287,8 @@ module PuppetTest rescue Timeout::Error # just move on end + + Puppet::Test::TestHelper.after_each_test end def logstore diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb index 411bad37a..23b248615 100644 --- a/test/lib/puppettest/parsertesting.rb +++ b/test/lib/puppettest/parsertesting.rb @@ -55,7 +55,6 @@ module PuppetTest::ParserTesting end def mkparser - Puppet::Node::Environment.clear Puppet::Parser::Parser.new(Puppet::Node::Environment.new) end