[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1456-g2f0b1e5

James Turnbull james at lovedthanlost.net
Tue Oct 27 17:06:16 UTC 2009


The following commit has been merged in the upstream branch:
commit febe7074d2188e1133503ebc5eade5403a6e271e
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Sun Oct 25 22:36:53 2009 -0700

    Bug #1742 Invalid params to --color outputs 'nil'
    
    This patches fixes a bug where setting an invalid option for "--color"
    caused the word "nil" to be printed on every line of the log, instead
    of printing out log messages.
    Invalid color options now just produce uncolored output.
    It seems to me that this isn't important enough to issue a warning
    about an invalid setting.
    
    Signed-off-by: Jesse Wolfe <jes5199 at gmail.com>

diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb
index 25c4677..4cdad70 100644
--- a/lib/puppet/util/log.rb
+++ b/lib/puppet/util/log.rb
@@ -282,9 +282,9 @@ class Puppet::Util::Log
 
         def colorize(level, str)
             case Puppet[:color]
-            when false; str
-            when true, :ansi, "ansi"; console_color(level, str)
+            when true, :ansi, "ansi", :yes, "yes"; console_color(level, str)
             when :html, "html"; html_color(level, str)
+            else str
             end
         end
 
diff --git a/spec/unit/util/log.rb b/spec/unit/util/log.rb
index 4e2c8dc..35e6a71 100755
--- a/spec/unit/util/log.rb
+++ b/spec/unit/util/log.rb
@@ -13,6 +13,42 @@ describe Puppet::Util::Log do
         Puppet::Util::Log.close_all
     end
 
+    describe Puppet::Util::Log::DestConsole do
+        before do
+            @console = Puppet::Util::Log::DestConsole.new 
+        end
+
+        it "should colorize if Puppet[:color] is :ansi" do
+            Puppet[:color] = :ansi
+
+            @console.colorize(:alert, "abc").should == "\e[0;31mabc\e[0m"
+        end
+
+        it "should colorize if Puppet[:color] is 'yes'" do
+            Puppet[:color] = "yes"
+
+            @console.colorize(:alert, "abc").should == "\e[0;31mabc\e[0m"
+        end
+
+        it "should htmlize if Puppet[:color] is :html" do
+            Puppet[:color] = :html
+
+            @console.colorize(:alert, "abc").should == "<span style=\"color: FFA0A0\">abc</span>"
+        end
+
+        it "should do nothing if Puppet[:color] is false" do
+            Puppet[:color] = false
+
+            @console.colorize(:alert, "abc").should == "abc"
+        end
+
+        it "should do nothing if Puppet[:color] is invalid" do
+            Puppet[:color] = "invalid option"
+
+            @console.colorize(:alert, "abc").should == "abc"
+        end
+    end
+
     describe "instances" do
         before do
             Puppet::Util::Log.stubs(:newmessage)

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list