summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-03 02:49:04 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-03 02:49:04 +0000
commitf797487ee2672c7e91b74c57d839cd52102a16d1 (patch)
treeaa1595a97780f7e6f96cb35ac000f0b313add0e3
parentff18e5592467c4b8fe2cedf48cd8f9332e0eff32 (diff)
downloadpuppet-f797487ee2672c7e91b74c57d839cd52102a16d1.tar.gz
puppet-f797487ee2672c7e91b74c57d839cd52102a16d1.tar.xz
puppet-f797487ee2672c7e91b74c57d839cd52102a16d1.zip
Fixing #239 -- missing checks now throw an ArgumentError. This will break if any command purposefully returns 127, but that would be a bug anyway, I suppose.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1540 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xlib/puppet/type/exec.rb5
-rwxr-xr-xtest/types/exec.rb12
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index ffb4415a1..0dc3ec02a 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -515,6 +515,11 @@ module Puppet
end
}
status = $?.dup
+
+ # The shell returns 127 if the command is missing.
+ if $?.exitstatus == 127
+ raise ArgumentError, output
+ end
}
rescue Errno::ENOENT => detail
self.fail detail.to_s
diff --git a/test/types/exec.rb b/test/types/exec.rb
index 4f66da517..16979c7ce 100755
--- a/test/types/exec.rb
+++ b/test/types/exec.rb
@@ -531,6 +531,18 @@ class TestExec < Test::Unit::TestCase
assert(! exec.check, "Check passed")
}
end
+
+ def test_missing_checks_cause_failures
+ exec = Puppet::Type.newexec(
+ :command => "echo true",
+ :path => ENV["PATH"],
+ :onlyif => "/bin/nosuchthingexists"
+ )
+
+ assert_raise(ArgumentError, "Missing command did not raise error") {
+ exec.run("/bin/nosuchthingexists")
+ }
+ end
end
# $Id$