summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/types/exec.rb40
-rwxr-xr-xtest/util/execution.rb4
2 files changed, 42 insertions, 2 deletions
diff --git a/test/types/exec.rb b/test/types/exec.rb
index 16979c7ce..8f0756b9f 100755
--- a/test/types/exec.rb
+++ b/test/types/exec.rb
@@ -543,6 +543,46 @@ class TestExec < Test::Unit::TestCase
exec.run("/bin/nosuchthingexists")
}
end
+
+ def test_envparam
+ exec = Puppet::Type.newexec(
+ :command => "echo $envtest",
+ :path => ENV["PATH"],
+ :env => "envtest=yayness"
+ )
+
+ assert(exec, "Could not make exec")
+
+ output = status = nil
+ assert_nothing_raised {
+ output, status = exec.run("echo $envtest")
+ }
+
+ assert_equal("yayness\n", output)
+
+ # Now check whether we can do multiline settings
+ assert_nothing_raised do
+ exec[:env] = "envtest=a list of things
+and stuff"
+ end
+
+ output = status = nil
+ assert_nothing_raised {
+ output, status = exec.run('echo "$envtest"')
+ }
+ assert_equal("a list of things\nand stuff\n", output)
+
+ # Now test arrays
+ assert_nothing_raised do
+ exec[:env] = ["funtest=A", "yaytest=B"]
+ end
+
+ output = status = nil
+ assert_nothing_raised {
+ output, status = exec.run('echo "$funtest" "$yaytest"')
+ }
+ assert_equal("A B\n", output)
+ end
end
# $Id$
diff --git a/test/util/execution.rb b/test/util/execution.rb
index 4df606806..ec56c84bb 100755
--- a/test/util/execution.rb
+++ b/test/util/execution.rb
@@ -16,12 +16,12 @@ class TestPuppetUtilExecution < Test::Unit::TestCase
assert_nothing_raised do
Puppet::Util::Execution.withenv :testing => "foo" do
- $ran = true
+ $ran = ENV["testing"]
end
end
assert_equal("yay", ENV["testing"])
- assert_equal(true, $ran)
+ assert_equal("foo", $ran)
ENV["rah"] = "yay"
assert_raise(ArgumentError) do