From f8afe131699f1f0afe834b070af285fd56f6320d Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 13 Feb 2008 16:52:26 -0600 Subject: Fixed #1043 -- autoloading now searches the plugins directory in each module, in addition to the lib directory. The 'lib' directory is also deprecated, but supported for now to give people a chance to convert. --- test/util/autoload.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/util/autoload.rb') diff --git a/test/util/autoload.rb b/test/util/autoload.rb index 6babed774..3fe18352c 100755 --- a/test/util/autoload.rb +++ b/test/util/autoload.rb @@ -123,4 +123,23 @@ TestAutoload.newthing(:#{name.to_s}) Kernel.expects(:require).with(File.join(loadname, subname)) loader.loadall end + + def test_searchpath_includes_plugin_dirs + moddir = "/what/ever" + libdir = "/other/dir" + Puppet.settings.stubs(:value).with(:modulepath).returns(moddir) + Puppet.settings.stubs(:value).with(:libdir).returns(libdir) + + loadname = "testing" + loader = Puppet::Util::Autoload.new(self.class, loadname) + + # Currently, include both plugins and libs. + paths = %w{plugins lib}.inject({}) { |hash, d| hash[d] = File.join(moddir, "testing", d); FileTest.stubs(:directory?).with(hash[d]).returns(true); hash } + Dir.expects(:glob).with("#{moddir}/*/{plugins,lib}").returns(paths.values) + + searchpath = loader.searchpath + paths.each do |dir, path| + assert(searchpath.include?(path), "search path did not include path for %s" % dir) + end + end end -- cgit