[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:04:01 UTC 2010


The following commit has been merged in the upstream branch:
commit fbedb999e4f4cc8020bc6be4a1d8868368c3ed7f
Author: Luke Kanies <luke at reductivelabs.com>
Date:   Mon Dec 21 17:05:47 2009 -0800

    Fixing #3148 Settings#without_noop when run with no noop setting
    
    Some tests didn't define this setting which caused this method
    to fail.
    
    Signed-off-by: Luke Kanies <luke at reductivelabs.com>

diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index df07d5c..532fce9 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -67,7 +67,7 @@ class Puppet::Util::Settings
             unsafe_clear(exceptcli)
         end
     end
-    
+
     # Remove all set values, potentially skipping cli values.
     def unsafe_clear(exceptcli = false)
         @values.each do |name, values|
@@ -162,6 +162,13 @@ class Puppet::Util::Settings
         set_value(str, value, :cli)
     end
 
+    def without_noop
+        old_noop = value(:noop,:cli) and set_value(:noop, false, :cli) if valid?(:noop)
+        yield
+    ensure
+        set_value(:noop, old_noop, :cli) if valid?(:noop)
+    end
+
     def include?(name)
         name = name.intern if name.is_a? String
         @config.include?(name)
@@ -675,7 +682,7 @@ Generated on #{Time.now}.
             end
             throw :foundval, nil
         end
-        
+
         # If we didn't get a value, use the default
         val = @config[param].default if val.nil?
 
diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb
index 5642813..645b543 100755
--- a/spec/unit/util/settings.rb
+++ b/spec/unit/util/settings.rb
@@ -1018,4 +1018,27 @@ describe Puppet::Util::Settings do
 
         it "should cache the result"
     end
+
+    describe "#without_noop" do
+        before do
+            @settings = Puppet::Util::Settings.new
+            @settings.setdefaults :main, :noop => [true, ""]
+        end
+
+        it "should set noop to false for the duration of the block" do
+            @settings.without_noop { @settings.value(:noop, :cli).should be_false }
+        end
+
+        it "should ensure that noop is returned to its previous value" do
+            @settings.without_noop { raise } rescue nil
+            @settings.value(:noop, :cli).should be_true
+        end
+
+        it "should work even if no 'noop' setting is available" do
+            settings = Puppet::Util::Settings.new
+            stuff = nil
+            settings.without_noop { stuff = "yay" }
+            stuff.should == "yay"
+        end
+    end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list