summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-07-10 04:48:43 +0000
committerLuke Kanies <luke@madstop.com>2005-07-10 04:48:43 +0000
commit4157fa01f499bdcdba19a0a6096f14cb1dc710ab (patch)
treeb584f1f31eaa1a3094493fc27b2bbe3f13aff80a
parent2c1f6373802c3d1431cce7e750764b286b62c41c (diff)
downloadpuppet-4157fa01f499bdcdba19a0a6096f14cb1dc710ab.tar.gz
puppet-4157fa01f499bdcdba19a0a6096f14cb1dc710ab.tar.xz
puppet-4157fa01f499bdcdba19a0a6096f14cb1dc710ab.zip
exec stuff all works now, end to end
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@349 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xlib/puppet/type/exec.rb23
-rwxr-xr-xtest/types/tc_exec.rb30
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