summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/compiler.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-07-21 17:38:57 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-07-25 11:58:43 +1000
commiteeec8e99eaeb6bb97173f2bc04148bff3be58036 (patch)
tree75fa94feb43fbf807585d06e090d49cf2828cc4a /spec/unit/parser/compiler.rb
parent7d40f9e039964e2c3f9e94b5ef2ccbded45a59a5 (diff)
downloadpuppet-eeec8e99eaeb6bb97173f2bc04148bff3be58036.tar.gz
puppet-eeec8e99eaeb6bb97173f2bc04148bff3be58036.tar.xz
puppet-eeec8e99eaeb6bb97173f2bc04148bff3be58036.zip
Fixing #2423 - no more strange dependency cycles
We were getting strange dependency cycles because our class structure mirrored our scope structure. We can't change the scope structure without switching from a dynamically scoped language to a lexically scoped language, which is too big of a change to make right now. Instead, I'm changing the resource graph so that all classes default to just having an edge to the 'main' graph. This will be a behaviour change for many, in that you were getting automatic dependencies from this old behaviour, but it will bring consistency. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/parser/compiler.rb')
-rwxr-xr-xspec/unit/parser/compiler.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/unit/parser/compiler.rb b/spec/unit/parser/compiler.rb
index ed439e16d..2459978e2 100755
--- a/spec/unit/parser/compiler.rb
+++ b/spec/unit/parser/compiler.rb
@@ -269,6 +269,29 @@ describe Puppet::Parser::Compiler do
lambda { @compiler.add_resource(@scope, file2) }.should raise_error(Puppet::Resource::Catalog::DuplicateResourceError)
end
+ it "should add an edge from the scope resource to the added resource" do
+ resource = stub "noconflict", :ref => "File[yay]"
+ @compiler.add_resource(@scope, resource)
+
+ @compiler.catalog.should be_edge(@scope.resource, resource)
+ end
+
+ it "should add edges from the class resources to the main class" do
+ main = CompilerTestResource.new(:class, :main)
+ @compiler.add_resource(@scope, main)
+ resource = CompilerTestResource.new(:class, "foo")
+ @compiler.add_resource(@scope, resource)
+
+ @compiler.catalog.should be_edge(main, resource)
+ end
+
+ it "should just add edges to the scope resource for the class resources when no main class can be found" do
+ resource = CompilerTestResource.new(:class, "foo")
+ @compiler.add_resource(@scope, resource)
+
+ @compiler.catalog.should be_edge(@scope.resource, resource)
+ end
+
it "should have a method for looking up resources" do
resource = stub 'resource', :ref => "Yay[foo]"
@compiler.add_resource(@scope, resource)