diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-01 19:24:58 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-01 19:24:58 +0000 |
commit | f80bd5e41623f2bdb8c5495caa12274c36e1cad3 (patch) | |
tree | 242369b7d2e976b3be8108ba237c36c7631a5558 | |
parent | d117aa835fdce43f57c5a24743411da847570532 (diff) | |
download | puppet-f80bd5e41623f2bdb8c5495caa12274c36e1cad3.tar.gz puppet-f80bd5e41623f2bdb8c5495caa12274c36e1cad3.tar.xz puppet-f80bd5e41623f2bdb8c5495caa12274c36e1cad3.zip |
Fixing exec so it actually works when path is specified as an array
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2155 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-x | lib/puppet/type/exec.rb | 2 | ||||
-rwxr-xr-x | test/test | 3 | ||||
-rwxr-xr-x | test/types/exec.rb | 21 |
3 files changed, 25 insertions, 1 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 04ba9fa6c..01870770c 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -179,7 +179,7 @@ module Puppet # Support both arrays and colon-separated fields. def value=(*values) - @value = values.collect { |val| + @value = values.flatten.collect { |val| val.split(":") }.flatten end @@ -10,6 +10,7 @@ require 'getoptlong' include Find result = GetoptLong.new( + [ "--build", "-b", GetoptLong::NO_ARGUMENT ], [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ], [ "--help", "-h", GetoptLong::NO_ARGUMENT ] @@ -21,6 +22,8 @@ $options = {} result.each { |opt,arg| case opt + when "--build" + $options[:build] = true when "--verbose" $options[:verbose] = true when "--debug" diff --git a/test/types/exec.rb b/test/types/exec.rb index 918fa62be..7718825ee 100755 --- a/test/types/exec.rb +++ b/test/types/exec.rb @@ -641,6 +641,27 @@ and stuff" ) end end + + # make sure paths work both as arrays and strings + def test_paths_as_arrays + path = %w{/usr/bin /usr/sbin /sbin} + exec = nil + assert_nothing_raised("Could not use an array for the path") do + exec = Puppet::Type.type(:exec).create(:command => "echo yay", + :path => path) + end + assert_equal(path, exec[:path], "array-based path did not match") + assert_nothing_raised("Could not use a string for the path") do + exec = Puppet::Type.type(:exec).create(:command => "echo yay", + :path => path.join(":")) + end + assert_equal(path, exec[:path], "string-based path did not match") + assert_nothing_raised("Could not use a colon-separated strings in an array for the path") do + exec = Puppet::Type.type(:exec).create(:command => "echo yay", + :path => ["/usr/bin", "/usr/sbin:/sbin"]) + end + assert_equal(path, exec[:path], "colon-separated array path did not match") + end end # $Id$ |