Codebase list facter / 7e983cb
Merge branch 'hkenney-ticket/master/14467_warn_when_removing_relative_paths' * hkenney-ticket/master/14467_warn_when_removing_relative_paths: (#14467) Warn when removing relative paths Jeff Weiss 11 years ago
3 changed file(s) with 25 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6060 # This allows others to register additional paths we should search.
6161 result += Facter.search_path
6262
63 result.select { |dir| valid_search_path? dir }
63 result.select do |dir|
64 good = valid_search_path? dir
65 Facter.debugonce("Relative directory #{dir} removed from search path.") unless good
66 good
67 end
6468 end
6569
6670 def valid_search_path?(path)
4343 @@debug = 0
4444 @@timing = 0
4545 @@messages = {}
46 @@debug_messages = {}
4647
4748 # module methods
4849
6768 puts GREEN + string + RESET
6869 end
6970 end
71
72 # Debug once.
73 def self.debugonce(msg)
74 if msg and not msg.empty? and @@debug_messages[msg].nil?
75 @@debug_messages[msg] = true
76 debug(msg)
77 end
78 end
7079
7180 def self.debugging?
7281 @@debug != 0
109109 paths.should be_include(dir)
110110 end
111111 end
112
112
113 it "should warn the user when an invalid search path has been excluded" do
114 dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") }
115 @loader.stubs(:valid_search_path?).returns(false)
116 dirs.each do |dir|
117 Facter.expects(:debugonce).with("Relative directory #{dir} removed from search path.").once
118 end
119 paths = @loader.search_path
120 end
121
122
113123 it "should exclude invalid search paths" do
114124 dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") }
115125 @loader.stubs(:valid_search_path?).returns(false)