diff options
-rwxr-xr-x | lib/puppet/type/exec.rb | 23 | ||||
-rwxr-xr-x | test/types/tc_exec.rb | 30 |
2 files changed, 44 insertions, 9 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index e981e67ca..421a1089a 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -48,6 +48,7 @@ module Puppet self.parent[:command] ) end + self.is = nil end def sync @@ -60,10 +61,7 @@ module Puppet ENV["PATH"] = tmppath - Puppet.debug("%s: status: %s; returns: %s" % - [self.parent[:command],status.exitstatus, self.should] - ) - if status.exitstatus != self.should + if status.exitstatus.to_s != self.should.to_s Puppet.err("%s returned %s" % [self.parent[:command],status.exitstatus]) @@ -80,9 +78,6 @@ module Puppet class Type class Exec < Type - attr_reader :command, :user, :returns - # class instance variable - # this is kind of hackish, using the return value as the # state, but apparently namevars can't also be states # who knew? @@ -101,10 +96,20 @@ module Puppet def initialize(hash) # default to erroring on a non-zero return - unless hash.include?("returns") or hash.include?(:returns) - hash["returns"] = 0 + if hash.include?("returns") + if hash["returns"].is_a?(Fixnum) + hash["returns"] = hash["returns"].to_s + end + elsif hash.include?(:returns) + if hash["returns"].is_a?(Fixnum) + hash[:returns] = hash[:returns].to_s + end + else + Puppet.debug("setting return to 0") + hash[:returns] = "0" end + super if self[:command].nil? diff --git a/test/types/tc_exec.rb b/test/types/tc_exec.rb index d188c4487..bc6b7dfaf 100755 --- a/test/types/tc_exec.rb +++ b/test/types/tc_exec.rb @@ -36,6 +36,36 @@ class TestExec < Test::Unit::TestCase assert_equal([:executed_command],output) end + def test_numvsstring + command = nil + output = nil + assert_nothing_raised { + command = Puppet::Type::Exec.new( + :command => "/bin/echo", + :returns => 0 + ) + } + assert_nothing_raised { + command.retrieve + } + assert_nothing_raised { + output = command.sync + } + Puppet::Type::Exec.clear + assert_nothing_raised { + command = Puppet::Type::Exec.new( + :command => "/bin/echo", + :returns => "0" + ) + } + assert_nothing_raised { + command.retrieve + } + assert_nothing_raised { + output = command.sync + } + end + def test_path_or_qualified command = nil output = nil |