diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-03 02:49:04 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-03 02:49:04 +0000 |
| commit | f797487ee2672c7e91b74c57d839cd52102a16d1 (patch) | |
| tree | aa1595a97780f7e6f96cb35ac000f0b313add0e3 | |
| parent | ff18e5592467c4b8fe2cedf48cd8f9332e0eff32 (diff) | |
| download | puppet-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-x | lib/puppet/type/exec.rb | 5 | ||||
| -rwxr-xr-x | test/types/exec.rb | 12 |
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$ |
