summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/compiler.rb
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-02-05 23:15:59 +0100
committerJames Turnbull <james@lovedthanlost.net>2009-02-14 22:32:07 +1100
commitd5abdfba8a88afda8085992a4abbe1d90bbd0084 (patch)
treea06a85798989fb25502b50c0cd2afaa347d8ad5f /spec/unit/parser/compiler.rb
parent3fbec120768d84d208b14f574dfe916e25cfdbef (diff)
downloadpuppet-d5abdfba8a88afda8085992a4abbe1d90bbd0084.tar.gz
puppet-d5abdfba8a88afda8085992a4abbe1d90bbd0084.tar.xz
puppet-d5abdfba8a88afda8085992a4abbe1d90bbd0084.zip
Fix #1933 - Inconsistent resource evaluation order in subsequent evaluation runs
While evaluating the AST, catalog vertices are not always ordered the same way on different run, leading to some tags (which should have been applied in evaluation order) to not be associated with some underlying resources. This changeset change all accesses to resources inside the compiler to always use an ordered (in evaluation order) list of added resources. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parser/compiler.rb')
-rwxr-xr-xspec/unit/parser/compiler.rb27
1 files changed, 26 insertions, 1 deletions
diff --git a/spec/unit/parser/compiler.rb b/spec/unit/parser/compiler.rb
index f36b6fd4f..855a8c723 100755
--- a/spec/unit/parser/compiler.rb
+++ b/spec/unit/parser/compiler.rb
@@ -239,6 +239,31 @@ describe Puppet::Parser::Compiler do
@compiler.send(:finish)
end
+ it "should call finish() in add_resource order" do
+ resources = sequence('resources')
+
+ resource1 = Puppet::Parser::Resource.new :scope => @scope, :type => "file", :title => "finish1"
+ resource1.expects(:finish).in_sequence(resources)
+
+ @compiler.add_resource(@scope, resource1)
+
+ resource2 = Puppet::Parser::Resource.new :scope => @scope, :type => "file", :title => "finish2"
+ resource2.expects(:finish).in_sequence(resources)
+
+ @compiler.add_resource(@scope, resource2)
+
+ @compiler.send(:finish)
+ end
+
+ it "should return added resources in add order" do
+ resource1 = stub "1", :ref => "File[yay]"
+ @compiler.add_resource(@scope, resource1)
+ resource2 = stub "2", :ref => "File[youpi]"
+ @compiler.add_resource(@scope, resource2)
+
+ @compiler.resources.should == [resource1, resource2]
+ end
+
it "should add resources that do not conflict with existing resources" do
resource = stub "noconflict", :ref => "File[yay]"
@compiler.add_resource(@scope, resource)
@@ -484,7 +509,7 @@ describe Puppet::Parser::Compiler do
Puppet.features.expects(:rails?).returns(true)
Puppet::Rails.expects(:connect)
- @compiler.catalog.expects(:vertices).returns(:resources)
+ @compiler.expects(:resources).returns(:resources)
@compiler.expects(:store_to_active_record).with(@node, :resources)
@compiler.send(:store)