diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-05 23:20:45 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-05 23:20:45 +0000 |
| commit | fcc5bae22cb2a0286975cfc0bcab52a2a7f7973d (patch) | |
| tree | 6ebe72a068a216cd56f6938b4d90fe0eaa86671b /test | |
| parent | 8310c9d18a89e499b63a10e7890d836dcfc86f46 (diff) | |
| download | puppet-fcc5bae22cb2a0286975cfc0bcab52a2a7f7973d.tar.gz puppet-fcc5bae22cb2a0286975cfc0bcab52a2a7f7973d.tar.xz puppet-fcc5bae22cb2a0286975cfc0bcab52a2a7f7973d.zip | |
Adding an "env" parameter to exec, for providing extra environment settings, as requested in #236.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1568 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rwxr-xr-x | test/types/exec.rb | 40 | ||||
| -rwxr-xr-x | test/util/execution.rb | 4 |
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 |
