diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-07 17:29:37 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-07 17:29:37 +0000 |
| commit | dd71a514b6970d3b4f8167a4f29849b1b1fc631d (patch) | |
| tree | 7259e906d9f3b288919d29790a0c3a6c347c8330 | |
| parent | 31c9a6fc7c2bff76a5c3d49a89111dd3c84706df (diff) | |
| download | puppet-dd71a514b6970d3b4f8167a4f29849b1b1fc631d.tar.gz puppet-dd71a514b6970d3b4f8167a4f29849b1b1fc631d.tar.xz puppet-dd71a514b6970d3b4f8167a4f29849b1b1fc631d.zip | |
Changing exec so that the checks apply to whether an exec is refreshed.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2172 980ebf18-57e1-0310-9a29-db15c13687c0
| -rwxr-xr-x | lib/puppet/type/exec.rb | 4 | ||||
| -rwxr-xr-x | test/ral/types/exec.rb | 40 |
2 files changed, 43 insertions, 1 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 55b3eb271..4a5bbd08f 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -486,7 +486,9 @@ module Puppet # this might be a very, very bad idea... def refresh - self.property(:returns).sync + if self.check + self.property(:returns).sync + end end # Run a command. diff --git a/test/ral/types/exec.rb b/test/ral/types/exec.rb index ed7acbd25..d16392921 100755 --- a/test/ral/types/exec.rb +++ b/test/ral/types/exec.rb @@ -662,6 +662,46 @@ and stuff" end assert_equal(path, exec[:path], "colon-separated array path did not match") end + + def test_checks_apply_to_refresh + file = tempfile() + maker = tempfile() + exec = Puppet::Type.type(:exec).create( + :title => "maker", + :command => "touch #{maker}", + :path => ENV["PATH"] + ) + + # Make sure it runs normally + assert_apply(exec) + assert(FileTest.exists?(maker), "exec did not run") + File.unlink(maker) + + # Now make sure it refreshes + assert_nothing_raised("Failed to refresh exec") do + exec.refresh + end + assert(FileTest.exists?(maker), "exec did not run refresh") + File.unlink(maker) + + # Now add the checks + exec[:creates] = file + + # Make sure it runs when the file doesn't exist + assert_nothing_raised("Failed to refresh exec") do + exec.refresh + end + assert(FileTest.exists?(maker), "exec did not refresh when checks passed") + File.unlink(maker) + + # Now create the file and make sure it doesn't refresh + File.open(file, "w") { |f| f.puts "" } + assert_nothing_raised("Failed to refresh exec") do + exec.refresh + end + assert(! FileTest.exists?(maker), "exec refreshed with failing checks") + + end end # $Id$ |
