diff options
author | Luke Kanies <luke@madstop.com> | 2005-07-11 20:21:41 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-07-11 20:21:41 +0000 |
commit | 0417fb59f4493b98fea9b03a60cb21ffc0f8bed4 (patch) | |
tree | 8357acb0051cbd471a64e43d0581329dc7875044 | |
parent | 6e9975ce229f889784f45d5b5c3434db3e0da30a (diff) | |
download | puppet-0417fb59f4493b98fea9b03a60cb21ffc0f8bed4.tar.gz puppet-0417fb59f4493b98fea9b03a60cb21ffc0f8bed4.tar.xz puppet-0417fb59f4493b98fea9b03a60cb21ffc0f8bed4.zip |
adding refreshonly parameter
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@358 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-x | lib/puppet/type/exec.rb | 11 | ||||
-rwxr-xr-x | test/types/tc_exec.rb | 50 |
2 files changed, 56 insertions, 5 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 2ae401cca..e07ad90b5 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -49,7 +49,15 @@ module Puppet self.parent[:command] ) end - self.is = nil + + if self.parent[:refreshonly] + # if refreshonly is enabled, then set things so we + # won't sync + self.is = self.should + else + # else, just set it to something we know it won't be + self.is = nil + end end def sync @@ -115,6 +123,7 @@ module Puppet :path, :user, :cwd, + :refreshonly, :command ] diff --git a/test/types/tc_exec.rb b/test/types/tc_exec.rb index e714caf82..42256dbcb 100755 --- a/test/types/tc_exec.rb +++ b/test/types/tc_exec.rb @@ -28,7 +28,7 @@ class TestExec < Test::Unit::TestCase ) } assert_nothing_raised { - command.retrieve + command.evaluate } assert_nothing_raised { output = command.sync @@ -46,7 +46,7 @@ class TestExec < Test::Unit::TestCase ) } assert_nothing_raised { - command.retrieve + command.evaluate } assert_nothing_raised { output = command.sync @@ -59,7 +59,7 @@ class TestExec < Test::Unit::TestCase ) } assert_nothing_raised { - command.retrieve + command.evaluate } assert_nothing_raised { output = command.sync @@ -131,11 +131,53 @@ class TestExec < Test::Unit::TestCase ) } assert_nothing_raised { - command.retrieve + command.evaluate } assert_nothing_raised { command.sync } assert_equal("/tmp\n",command.output) end + + def test_refreshonly + file = nil + cmd = nil + tmpfile = "/tmp/testing" + trans = nil + File.open(tmpfile, File::WRONLY|File::CREAT|File::APPEND) { |of| + of.puts "yayness" + } + file = Puppet::Type::PFile.new( + :path => tmpfile, + :checksum => "md5" + ) + assert_nothing_raised { + cmd = Puppet::Type::Exec.new( + :command => "pwd", + :path => "/usr/bin:/bin:/usr/sbin:/sbin", + :require => [[file.class.name,file.name]], + :refreshonly => true + ) + } + comp = Puppet::Component.new(:name => "RefreshTest") + [file,cmd].each { |obj| + comp.push obj + } + assert_nothing_raised { + trans = comp.evaluate + } + events = nil + assert_nothing_raised { + events = trans.evaluate.collect { |event| + event.event + } + } + + # verify that only the file_changed event was kicked off, not the + # command_executed + assert_equal( + ["file_changed"], + events + ) + end end |