[Pkg-puppet-devel] [facter] 223/352: (maint) Reset facter search path when resetting facts
Stig Sandbeck Mathisen
ssm at debian.org
Sun Apr 6 22:21:47 UTC 2014
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit 9e59aeb7db0a61123538bbbcfdc9fc14356e99ca
Author: Adrien Thebo <git at somethingsinistral.net>
Date: Wed Feb 5 11:30:41 2014 -0800
(maint) Reset facter search path when resetting facts
The previous implementation of Facter search paths was only additive and
there was no way to remove Facter search paths once added. This is
especially problematic when running the Puppet specs which wind up
reloading Facter frequently and adding search paths, and can wind up
adding thousands of meaningless paths. This commit resets the Facter
search path on `Facter.reset` so that when facts are reset, the known
search pats are reset as well.
---
lib/facter.rb | 13 +++++++++++--
spec/unit/facter_spec.rb | 2 +-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/facter.rb b/lib/facter.rb
index 68b3d7b..e85c99b 100644
--- a/lib/facter.rb
+++ b/lib/facter.rb
@@ -184,6 +184,7 @@ module Facter
# @api public
def self.reset
@collection = nil
+ reset_search_path!
end
# Loads all facts.
@@ -195,8 +196,6 @@ module Facter
collection.load_all
end
- @search_path = []
-
# Register directories to be searched for facts. The registered directories
# must be absolute paths or they will be ignored.
#
@@ -218,6 +217,16 @@ module Facter
@search_path.dup
end
+ # Reset the Facter search directories.
+ #
+ # @api private
+ # @return [void]
+ def self.reset_search_path!
+ @search_path = []
+ end
+
+ reset_search_path!
+
# Registers directories to be searched for external facts.
#
# @param dirs [Array<String>] directories to search
diff --git a/spec/unit/facter_spec.rb b/spec/unit/facter_spec.rb
index 6817446..1b87ef3 100755
--- a/spec/unit/facter_spec.rb
+++ b/spec/unit/facter_spec.rb
@@ -109,7 +109,7 @@ describe Facter do
end
describe "when registering directories to search" do
- after { Facter.instance_variable_set("@search_path", []) }
+ after { Facter.reset_search_path! }
it "should allow registration of a directory" do
Facter.search "/my/dir"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list