diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-18 19:25:15 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-18 19:25:15 +0000 |
commit | 8eddd4bcd23923a166e1ab7d81be1c1f2d341cdf (patch) | |
tree | f82d1ae8f6e5910b919e5f5ebe3d9ad3e44ab20c | |
parent | 2fe9998e0256a39b413d9e73a04ba4e7784ea3e6 (diff) | |
download | puppet-8eddd4bcd23923a166e1ab7d81be1c1f2d341cdf.tar.gz puppet-8eddd4bcd23923a166e1ab7d81be1c1f2d341cdf.tar.xz puppet-8eddd4bcd23923a166e1ab7d81be1c1f2d341cdf.zip |
More work on #542 -- services in noop now produce noop events so that they can themselves trigger further changes
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2295 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/transaction.rb | 8 | ||||
-rwxr-xr-x | test/other/transactions.rb | 30 |
2 files changed, 29 insertions, 9 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 7199ac3cd..328921ed8 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -690,7 +690,13 @@ class Transaction if noop resource.notice "Would have triggered %s from %s dependencies" % [callback, subs.length] - return nil + + # And then add an event for it. + return [Puppet::Event.new( + :event => :noop, + :transaction => self, + :source => resource + )] end if subs.length == 1 and subs[0].source == resource diff --git a/test/other/transactions.rb b/test/other/transactions.rb index d9451291e..a075a120e 100755 --- a/test/other/transactions.rb +++ b/test/other/transactions.rb @@ -4,6 +4,7 @@ $:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ require 'puppet' require 'puppettest' +require 'mocha' require 'puppettest/support/resources' # $Id$ @@ -1090,24 +1091,37 @@ class TestTransactions < Test::Unit::TestCase def test_noop_with_notify path = tempfile epath = tempfile - file = Puppet::Type.newfile(:path => path, :ensure => :file) + spath = tempfile + file = Puppet::Type.newfile(:path => path, :ensure => :file, + :title => "file") exec = Puppet::Type.type(:exec).create(:command => "touch %s" % epath, - :path => ENV["PATH"], :subscribe => file, :refreshonly => true) + :path => ENV["PATH"], :subscribe => file, :refreshonly => true, + :title => 'exec1') + exec2 = Puppet::Type.type(:exec).create(:command => "touch %s" % spath, + :path => ENV["PATH"], :subscribe => exec, :refreshonly => true, + :title => 'exec2') Puppet[:noop] = true assert(file.noop, "file not in noop") assert(exec.noop, "exec not in noop") - assert_apply(file, exec) + @logs.clear + assert_apply(file, exec, exec2) assert(! FileTest.exists?(path), "Created file in noop") assert(! FileTest.exists?(epath), "Executed exec in noop") - - logs = @logs.dup - assert_logged(:notice, /should be/, "did not log file change") - @logs = logs - assert_logged(:notice, /Would have triggered/, "did not log exec trigger") + assert(! FileTest.exists?(spath), "Executed second exec in noop") + + assert(@logs.detect { |l| + l.message =~ /should be/ and l.source == file.property(:ensure).path}, + "did not log file change") + assert(@logs.detect { |l| + l.message =~ /Would have/ and l.source == exec.path }, + "did not log first exec trigger") + assert(@logs.detect { |l| + l.message =~ /Would have/ and l.source == exec2.path }, + "did not log second exec trigger") end def test_only_stop_purging_with_relations |