[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Paul Berry
paul at puppetlabs.com
Tue May 10 08:02:05 UTC 2011
The following commit has been merged in the experimental branch:
commit cf18353472ce9c4e51157d21882a7f129853fd10
Author: Paul Berry <paul at puppetlabs.com>
Date: Thu Nov 18 13:21:35 2010 -0800
Maint: Switched spec tests to use a class rather than Array as the log destination.
Using an Array as a log destination is unreliable because Puppet's log
mechanism stores log destinations in a hash whose key is the
destination itself. Since arrays can change their hash when they are
modified, this was causing the log destination hash to become
corrupted, producing sporadic spec test failures.
diff --git a/lib/puppet/util/log/destinations.rb b/lib/puppet/util/log/destinations.rb
index 22b3ded..2e2f9a5 100644
--- a/lib/puppet/util/log/destinations.rb
+++ b/lib/puppet/util/log/destinations.rb
@@ -203,8 +203,20 @@ Puppet::Util::Log.newdesttype :report do
end
# Log to an array, just for testing.
+module Puppet::Test
+ class LogCollector
+ def initialize(logs)
+ @logs = logs
+ end
+
+ def <<(value)
+ @logs << value
+ end
+ end
+end
+
Puppet::Util::Log.newdesttype :array do
- match "Array"
+ match "Puppet::Test::LogCollector"
def initialize(messages)
@messages = messages
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index ed4e2c2..0c4b076 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -72,7 +72,7 @@ Spec::Runner.configure do |config|
Puppet.settings[:bindaddress] = "127.0.0.1"
@logs = []
- Puppet::Util::Log.newdestination(@logs)
+ Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs))
end
end
diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb
index 4cec710..ea5d598 100755
--- a/spec/unit/util/log_spec.rb
+++ b/spec/unit/util/log_spec.rb
@@ -7,7 +7,7 @@ require 'puppet/util/log'
describe Puppet::Util::Log do
it "should write a given message to the specified destination" do
arraydest = []
- Puppet::Util::Log.newdestination(arraydest)
+ Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(arraydest))
Puppet::Util::Log.new(:level => :notice, :message => "foo")
message = arraydest.last.message
message.should == "foo"
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 0b3a89a..a60092c 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -185,7 +185,7 @@ module PuppetTest
#if rake? or ! Puppet[:debug]
#if defined?($puppet_debug) or ! rake?
Puppet[:color] = false if textmate?
- Puppet::Util::Log.newdestination(@logs)
+ Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs))
if defined? $console
Puppet.info @method_name
Puppet::Util::Log.newdestination(:console)
@@ -305,7 +305,7 @@ module PuppetTest
def logstore
@logs = []
- Puppet::Util::Log.newdestination(@logs)
+ Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs))
end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list