[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.4-89-gcbbd363

James Turnbull james at lovedthanlost.net
Tue May 18 09:03:50 UTC 2010


The following commit has been merged in the upstream branch:
commit 751df45547162632c41cf98a1b1daabbadb1b901
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Sun Mar 21 12:07:37 2010 +0100

    Fix #3186 - require function set relationship only on the last class
    
    Due to the fact that resource.set_parameter is overwriting the previous
    set_parameters, we were losing the previous relationships we set there,
    either in a previous call of require or in the same call.
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/parser/functions/require.rb b/lib/puppet/parser/functions/require.rb
index 3e79619..f634f9f 100644
--- a/lib/puppet/parser/functions/require.rb
+++ b/lib/puppet/parser/functions/require.rb
@@ -50,7 +50,7 @@ fail if used with earlier clients.
             # but that is considered a containment edge, not a dependency
             # edge, so it usually gets lost on the client.
             ref = Puppet::Parser::Resource::Reference.new(:type => :class, :title => klass)
-            resource.set_parameter(:require, ref)
+            resource.set_parameter(:require, [resource[:require]].flatten.compact << ref)
         end
     end
 end
diff --git a/spec/integration/parser/functions/require.rb b/spec/integration/parser/functions/require.rb
index 960594b..6f169ad 100755
--- a/spec/integration/parser/functions/require.rb
+++ b/spec/integration/parser/functions/require.rb
@@ -22,10 +22,27 @@ describe "the require function" do
 
         @scope.function_require("requiredclass")
         @scope.resource["require"].should_not be_nil
-        ref = @scope.resource["require"]
+        ref = @scope.resource["require"].shift
         ref.type.should == "Class"
         ref.title.should == "requiredclass"
     end
+
+    it "should queue relationships between the 'required' class and our classes" do
+        @parser.newclass("requiredclass1")
+        @parser.newclass("requiredclass2")
+
+        @scope.function_require("requiredclass1")
+        @scope.function_require("requiredclass2")
+
+        @scope.resource["require"].should_not be_nil
+
+        (ref1,ref2) = @scope.resource["require"]
+        ref1.type.should == "Class"
+        ref1.title.should == "requiredclass1"
+        ref2.type.should == "Class"
+        ref2.title.should == "requiredclass2"
+    end
+
 end
 
 describe "the include function" do
diff --git a/spec/unit/parser/functions/require.rb b/spec/unit/parser/functions/require.rb
index 532c069..4e05069 100755
--- a/spec/unit/parser/functions/require.rb
+++ b/spec/unit/parser/functions/require.rb
@@ -8,7 +8,7 @@ describe "the require function" do
         @catalog = stub 'catalog'
         @compiler = stub 'compiler', :catalog => @catalog
 
-        @resource = stub 'resource', :set_parameter => nil, :metaparam_compatibility_mode? => false
+        @resource = stub 'resource', :set_parameter => nil, :metaparam_compatibility_mode? => false, :[] => nil
         @scope = Puppet::Parser::Scope.new()
         @scope.stubs(:resource).returns @resource
         @scope.stubs(:findresource)
@@ -28,7 +28,7 @@ describe "the require function" do
     end
 
     it "should set the 'require' prarameter on the resource to a resource reference" do
-        @resource.expects(:set_parameter).with { |name, value| name == :require and value.is_a?(Puppet::Parser::Resource::Reference) }
+        @resource.expects(:set_parameter).with { |name, value| name == :require and value[0].is_a?(Puppet::Parser::Resource::Reference) }
         @scope.stubs(:function_include)
         @scope.function_require("myclass")
     end
@@ -56,4 +56,14 @@ describe "the require function" do
 
         @scope.function_require("myclass")
     end
+
+    it "should append the required class to the require parameter" do
+        @scope.stubs(:function_include)
+        Puppet::Parser::Resource::Reference.stubs(:new).returns(:require2)
+
+        @resource.expects(:[]).with(:require).returns(:require1)
+        @resource.expects(:set_parameter).with(:require, [:require1, :require2])
+
+        @scope.function_require("myclass")
+    end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list