diff options
| author | mccune <mccune@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-04-03 15:51:18 +0000 |
|---|---|---|
| committer | mccune <mccune@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-04-03 15:51:18 +0000 |
| commit | efe9a833c43358e23ae252456a07b37cc9904a0a (patch) | |
| tree | 2597028c9ecb1b1677a63d807691b1a2c32498d8 /test | |
| parent | 8ab272265d30ea01322943c688e815ad772a571a (diff) | |
Fix for #565: Final merge of changes from source:branches/execute-refactor into source:trunk
Generated with
svn merge -r 2378:HEAD https://reductivelabs.com/svn/puppet/branches/execute-refactor trunk
CHANGES:
- Puppet::Util#execute now takes hash key/value pairs as arguments after the command array.
- Processes executed from the base service provider are now silenced. That is, their
standard input, output, and error pipes are all directed to /dev/null.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2385 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rw-r--r-- | test/README | 15 | ||||
| -rwxr-xr-x | test/util/utiltest.rb | 30 |
2 files changed, 36 insertions, 9 deletions
diff --git a/test/README b/test/README index 80d98b4bd..82a749a69 100644 --- a/test/README +++ b/test/README @@ -1,5 +1,15 @@ $Id$ +To run all tests, run: 'rake test'. To run an individual suite, run the file +directly. e.g. cd test/util; ./utiltest.rb + +You might need to run some tests as root. + +If you do not have rake installed: + gem install rake + +## The following information is possibly out of date? + Tests are organized into a dual hierarchy: each subdirectory is considered a test suite, and each file in the subdirectory is considered a test case. You can use any test case as an example of how to write @@ -12,8 +22,3 @@ if __FILE__ == $0 $:.unshift '../../lib' $blinkbase = "../.." end - -To run all tests, just type './test'. To run an individual suite, run -'./test <suite>'. To run an individual case, cd into the suite -subdirectory and run './tc_<case>.rb'. Tests are basically guaranteed -not to work without cd'ing into the subdirectory. diff --git a/test/util/utiltest.rb b/test/util/utiltest.rb index fd7c6c38f..07023d138 100755 --- a/test/util/utiltest.rb +++ b/test/util/utiltest.rb @@ -277,11 +277,15 @@ class TestPuppetUtil < Test::Unit::TestCase # Now try it with a single quote assert_nothing_raised do output = Puppet::Util.execute([command, "yay'test", "funtest"]) - # output = Puppet::Util.execute(command) - end assert_equal("yay'test\nfuntest\n", output) + # Now make sure we can squelch output (#565) + assert_nothing_raised do + output = Puppet::Util.execute([command, "yay'test", "funtest"], :squelch => true) + end + assert_equal(nil, output) + # Now test that we correctly fail if the command returns non-zero assert_raise(Puppet::ExecutionFailure) do out = Puppet::Util.execute(["touch", "/no/such/file/could/exist"]) @@ -289,7 +293,7 @@ class TestPuppetUtil < Test::Unit::TestCase # And that we can tell it not to fail assert_nothing_raised() do - out = Puppet::Util.execute(["touch", "/no/such/file/could/exist"], false) + out = Puppet::Util.execute(["touch", "/no/such/file/could/exist"], :failonfail => false) end if Process.uid == 0 @@ -298,7 +302,7 @@ class TestPuppetUtil < Test::Unit::TestCase group = nonrootgroup file = tempfile() assert_nothing_raised do - Puppet::Util.execute(["touch", file], true, user.name, group.name) + Puppet::Util.execute(["touch", file], :uid => user.name, :gid => group.name) end assert(FileTest.exists?(file), "file was not created") assert_equal(user.uid, File.stat(file).uid, "uid was not set correctly") @@ -308,6 +312,24 @@ class TestPuppetUtil < Test::Unit::TestCase # assert_equal(group.gid, File.stat(file).gid, # "gid was not set correctly") end + + # (#565) Test the case of patricide. + patricidecommand = tempfile() + File.open(patricidecommand, "w") { |f| + f.puts %{#!/bin/bash\n/bin/bash -c 'kill -TERM \$PPID' &;\n while [ 1 ]; do echo -n ''; done;\n} + } + File.chmod(0755, patricidecommand) + assert_nothing_raised do + output = Puppet::Util.execute([patricidecommand], :squelch => true) + end + assert_equal(nil, output) + # See what happens if we try and read the pipe to the command... + assert_raise(Puppet::ExecutionFailure) do + output = Puppet::Util.execute([patricidecommand]) + end + assert_nothing_raised do + output = Puppet::Util.execute([patricidecommand], :failonfail => false) + end end # Check whether execute() accepts strings in addition to arrays. |
