diff options
-rw-r--r-- | lib/puppet/transportable.rb | 8 | ||||
-rw-r--r-- | lib/puppet/type.rb | 21 | ||||
-rw-r--r-- | test/puppettest.rb | 4 | ||||
-rwxr-xr-x | test/types/exec.rb | 4 | ||||
-rw-r--r-- | test/types/type.rb | 3 |
5 files changed, 21 insertions, 19 deletions
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb index 0d775f7e0..90bc70fc2 100644 --- a/lib/puppet/transportable.rb +++ b/lib/puppet/transportable.rb @@ -264,9 +264,11 @@ module Puppet end # Now just call to_type on them with the container as a parent - unless obj = child.to_type(container) - # nothing; we assume the method already warned - #Puppet.warning "Could not create child %s" % child.name + begin + child.to_type(container) + rescue => detail + # We don't do anything on failures, since we assume it's + # been logged elsewhere. end } diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index f422940fe..19a77b4bc 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -365,13 +365,14 @@ class Type < Puppet::Element # Find the namevar def self.namevar unless defined? @namevar - return nil unless defined? @parameters and ! @parameters.empty? - namevarparam = @parameters.find { |param| - param.isnamevar? + params = @parameters.find_all { |param| + param.isnamevar? or param.name == :name } - if namevarparam - @namevar = namevarparam.name + if params.length > 1 + raise Puppet::DevError, "Found multiple namevars for %s" % self.name + elsif params.length == 1 + @namevar = params[0].name else raise Puppet::DevError, "No namevar for %s" % self.name end @@ -1388,22 +1389,18 @@ class Type < Puppet::Element end # create it anew - # if there's a failure, destroy the object if it got that far + # if there's a failure, destroy the object if it got that far, but raise + # the error. begin obj = new(hash) rescue => detail - unless detail.is_a? Puppet::Error - if Puppet[:debug] - puts detail.backtrace - end - end Puppet.err "Could not create %s: %s" % [title, detail.to_s] if obj obj.remove(true) elsif obj = self[title] obj.remove(true) end - return nil + raise end if implicit diff --git a/test/puppettest.rb b/test/puppettest.rb index f094045cd..f67b2dc96 100644 --- a/test/puppettest.rb +++ b/test/puppettest.rb @@ -59,6 +59,10 @@ module TestPuppet @methods = ary end + def self.default? + false + end + def self.initvars @calls = Hash.new do |hash, key| hash[key] = 0 diff --git a/test/types/exec.rb b/test/types/exec.rb index 8f0756b9f..8f09420d1 100755 --- a/test/types/exec.rb +++ b/test/types/exec.rb @@ -44,13 +44,11 @@ class TestExec < Test::Unit::TestCase def test_path_or_qualified command = nil output = nil - assert_nothing_raised { + assert_raise(Puppet::Error) { command = Puppet.type(:exec).create( :command => "echo" ) - assert_nil(command) } - Puppet.type(:exec).clear assert_nothing_raised { command = Puppet.type(:exec).create( :command => "echo", diff --git a/test/types/type.rb b/test/types/type.rb index 420024fb3..010102ad9 100644 --- a/test/types/type.rb +++ b/test/types/type.rb @@ -690,6 +690,7 @@ end def test_defaultproviders # Make a fake type type = Puppet::Type.newtype(:defaultprovidertest) do + newparam(:name) do end end basic = type.provide(:basic) do @@ -740,7 +741,7 @@ end end # This will fail, but earlier systems will catch it. - assert_nothing_raised do + assert_raise(Puppet::Error) do file2 = Puppet::Type.type(:file).create( :title => "file2", :path => path, |