summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/puppet/type/exec.rb2
-rwxr-xr-xspec/unit/provider/exec/posix_spec.rb13
-rw-r--r--spec/unit/provider/exec/shell_spec.rb18
3 files changed, 22 insertions, 11 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index 67d40a7cc..4458bf081 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -139,7 +139,7 @@ module Puppet
newparam(:path) do
desc "The search path used for command execution.
Commands must be fully qualified if no path is specified. Paths
- can be specified as an array or as a colon or semi-colon separated list."
+ can be specified as an array or as a colon separated list."
# Support both arrays and colon-separated fields.
def value=(*values)
diff --git a/spec/unit/provider/exec/posix_spec.rb b/spec/unit/provider/exec/posix_spec.rb
index a9b207533..d02099250 100755
--- a/spec/unit/provider/exec/posix_spec.rb
+++ b/spec/unit/provider/exec/posix_spec.rb
@@ -57,13 +57,18 @@ describe provider_class do
lambda { @provider.run("foo") }.should raise_error(ArgumentError, "'foo' is not executable")
end
+ it "should not be able to execute shell builtins" do
+ @provider.resource[:path] = ['/bin']
+ lambda { @provider.run("cd ..") }.should raise_error(ArgumentError, "Could not find command 'cd'")
+ end
+
it "should execute the command if the command given includes arguments or subcommands" do
@provider.resource[:path] = ['/bogus/bin']
File.stubs(:exists?).returns(false)
File.stubs(:exists?).with("foo").returns(true)
File.stubs(:executable?).with("foo").returns(true)
- Puppet::Util.expects(:execute).with(['foo bar --sillyarg=true --blah'], {:uid => nil, :gid => nil, :combine => true, :failonfail => false})
+ Puppet::Util.expects(:execute).with() { |command, arguments| (command == ['foo bar --sillyarg=true --blah']) && (arguments.is_a? Hash) }
@provider.run("foo bar --sillyarg=true --blah")
end
@@ -80,7 +85,7 @@ describe provider_class do
@provider.resource[:path] = ['/bogus/bin']
File.stubs(:exists?).with("foo").returns(true)
File.stubs(:executable?).with("foo").returns(true)
- Puppet::Util.expects(:execute).with(['foo'], {:uid => nil, :gid => nil, :combine => true, :failonfail => false})
+ Puppet::Util.expects(:execute).with() { |command, arguments| (command == ['foo']) && (arguments.is_a? Hash) }
@provider.run("foo")
end
@@ -92,7 +97,7 @@ describe provider_class do
File.stubs(:exists?).returns(false)
File.stubs(:exists?).with("/bogus/bin/foo#{extension}").returns(true)
File.stubs(:executable?).with("foo").returns(true)
- Puppet::Util.expects(:execute).with(['foo'], {:uid => nil, :gid => nil, :combine => true, :failonfail => false})
+ Puppet::Util.expects(:execute).with() { |command, arguments| (command == ['foo']) && (arguments.is_a? Hash) }
@provider.run("foo")
end
@@ -105,7 +110,7 @@ describe provider_class do
File.stubs(:exists?).with("foo").returns(true)
File.stubs(:executable?).with("foo").returns(true)
- Puppet::Util.expects(:execute).with(['foo'], {:uid => nil, :gid => nil, :combine => true, :failonfail => false})
+ Puppet::Util.expects(:execute).with() { |command, arguments| (command == ['foo']) && (arguments.is_a? Hash) }
@provider.run("foo")
@logs.map {|l| "#{l.level}: #{l.message}" }.should == ["warning: Overriding environment setting 'WHATEVER' with '/foo'"]
end
diff --git a/spec/unit/provider/exec/shell_spec.rb b/spec/unit/provider/exec/shell_spec.rb
index 44390ff08..a9b1f06ba 100644
--- a/spec/unit/provider/exec/shell_spec.rb
+++ b/spec/unit/provider/exec/shell_spec.rb
@@ -11,21 +11,27 @@ describe provider_class do
describe "#run" do
it "should be able to run builtin shell commands" do
- output, status = @provider.run("echo foo")
+ output, status = @provider.run("if [ 1 == 1 ]; then echo 'blah'; fi")
status.exitstatus.should == 0
- output.should == "foo\n"
+ output.should == "blah\n"
end
it "should be able to run commands with single quotes in them" do
- output, status = @provider.run("echo 'foo bar'")
+ output, status = @provider.run("echo 'foo bar'")
status.exitstatus.should == 0
- output.should == "foo bar\n"
+ output.should == "foo bar\n"
end
it "should be able to run commands with double quotes in them" do
- output, status = @provider.run("echo 'foo bar'")
+ output, status = @provider.run('echo "foo bar"')
status.exitstatus.should == 0
- output.should == "foo bar\n"
+ output.should == "foo bar\n"
+ end
+
+ it "should be able to run multiple commands separated by a semicolon" do
+ output, status = @provider.run("echo 'foo' ; echo 'bar'")
+ status.exitstatus.should == 0
+ output.should == "foo\nbar\n"
end
it "should be able to read values from the environment parameter" do