diff options
| -rw-r--r-- | Rakefile | 2 | ||||
| -rw-r--r-- | lib/puppet/parser/interpreter.rb | 6 | ||||
| -rwxr-xr-x | lib/puppet/type/parsedtype.rb | 13 | ||||
| -rwxr-xr-x | lib/puppet/type/parsedtype/port.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/pfile.rb | 2 | ||||
| -rwxr-xr-x | test/language/interpreter.rb | 10 | ||||
| -rwxr-xr-x | test/test | 15 | ||||
| -rwxr-xr-x | test/types/port.rb | 2 | ||||
| -rw-r--r-- | test/types/type.rb | 9 |
9 files changed, 42 insertions, 20 deletions
@@ -47,7 +47,7 @@ DOWNDIR = "/export/docroots/reductivelabs.com/htdocs/downloads" if ENV['HOSTS'] TESTHOSTS = ENV['HOSTS'].split(/\s+/) else - TESTHOSTS = %w{fedora1 rh3a kirby culain openbsd1 centos1} + TESTHOSTS = %w{fedora1 rh3a culain openbsd1 centos1} end #TESTHOSTS = %w{sol10b} diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index ce6a9935c..1ad039f06 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -83,7 +83,11 @@ module Puppet # Connect to the LDAP Server def setup_ldap - require 'ldap' + begin + require 'ldap' + rescue LoadError + @ldap = nil + end begin @ldap = LDAP::Conn.new(Puppet[:ldapserver], Puppet[:ldapport]) @ldap.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3) diff --git a/lib/puppet/type/parsedtype.rb b/lib/puppet/type/parsedtype.rb index 0429bcdd1..358c489ab 100755 --- a/lib/puppet/type/parsedtype.rb +++ b/lib/puppet/type/parsedtype.rb @@ -280,18 +280,9 @@ module Puppet self.store end - # We just find any state and check whether it's marked absent + # hash2obj marks the 'ensure' state as present def exists? - name, state = @states.find { |name, state| - state.is_a?(Puppet::State::ParsedParam) - } - - # Unless we've retrieved, we don't know if we exist - if ! state.is or state.is == :absent - return false - else - return true - end + @states.include?(:ensure) and @states[:ensure].is == :present end def destroy diff --git a/lib/puppet/type/parsedtype/port.rb b/lib/puppet/type/parsedtype/port.rb index 369d2aea3..feaa3afed 100755 --- a/lib/puppet/type/parsedtype/port.rb +++ b/lib/puppet/type/parsedtype/port.rb @@ -54,6 +54,7 @@ module Puppet newstate(:description) do desc "The port description." + isoptional end newstate(:alias) do @@ -62,6 +63,8 @@ module Puppet one of the metaparams; using this state to set aliases will make those aliases available in your Puppet scripts and also on disk." + isoptional + # We have to override the feeding mechanism; it might be nil or # white-space separated def is=(value) diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index 6f064ee2a..69f636bec 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -98,7 +98,7 @@ module Puppet cur = [] # Skip the nil in the beginning and don't add ourselves as a prereq # either. - self.name.split(File::SEPARATOR)[1..-2].collect { |dir| + self[:path].split(File::SEPARATOR)[1..-2].collect { |dir| cur << dir "/" + cur.join(File::SEPARATOR) } diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb index 6e8873986..bd112a8da 100755 --- a/test/language/interpreter.rb +++ b/test/language/interpreter.rb @@ -72,8 +72,15 @@ class TestInterpreter < Test::Unit::TestCase # Only test ldap stuff on luke's network, since that's the only place we # have data for. if Facter["domain"].value == "madstop.com" - def ldapconnect + begin require 'ldap' + $haveldap = true + rescue LoadError + $stderr.puts "Missing ldap; skipping ldap source tests" + $haveldap = false + end + if $haveldap + def ldapconnect @ldap = LDAP::Conn.new("ldap", 389) @ldap.set_option( LDAP::LDAP_OPT_PROTOCOL_VERSION, 3 ) @@ -154,4 +161,5 @@ class TestInterpreter < Test::Unit::TestCase } end end + end end @@ -16,31 +16,38 @@ require 'getoptlong' #[ "--size", "-s", GetoptLong::REQUIRED_ARGUMENT ], result = GetoptLong.new( [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], + [ "-n", GetoptLong::REQUIRED_ARGUMENT ], [ "--help", "-h", GetoptLong::NO_ARGUMENT ] ) usage = "USAGE: %s [--help] <testsuite> <testsuite> .." % $0 +opts = [] + result.each { |opt,arg| case opt when "--debug" - Puppet[:debug] = true + Puppet::Log.level = :debug when "--help" puts usage exit else - raise "Invalid option '#{opt}'" + opts << opt << arg + #raise "Invalid option '#{opt}'" end } - suites = nil if ARGV.length != 0 - suites = ARGV + suites = ARGV.dup else suites = PuppetTestSuite.list end +ARGV.clear + +opts.each { |o| ARGV << o } + suites.each { |suite| PuppetTestSuite.new(suite) } diff --git a/test/types/port.rb b/test/types/port.rb index c37f2dff0..77da6c825 100755 --- a/test/types/port.rb +++ b/test/types/port.rb @@ -186,6 +186,8 @@ class TestPort < Test::Unit::TestCase port.retrieve } + assert_equal(:present, port.is(:ensure)) + assert(port.state(:alias).is == :absent) port[:alias] = "yaytest" diff --git a/test/types/type.rb b/test/types/type.rb index abb3178c6..bb3a7f629 100644 --- a/test/types/type.rb +++ b/test/types/type.rb @@ -190,7 +190,14 @@ class TestType < Test::Unit::TestCase # Verify that names are aliases, not equivalents def test_nameasalias file = nil - path = tempfile() + # Create the parent dir, so we make sure autorequiring the parent dir works + parentdir = tempfile() + dir = Puppet.type(:file).create( + :name => parentdir, + :ensure => "directory" + ) + assert_apply(dir) + path = File.join(parentdir, "subdir") name = "a test file" transport = Puppet::TransObject.new(name, "file") transport[:path] = path |
