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 From 892055709a7e0b628758d24aba7590fd3c78426b Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 13 Feb 2008 17:29:23 -0600 Subject: Fixing #1064 -- providers et al are now autoloaded from modules even when Autoload#loadall is used. --- test/util/autoload.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/util/autoload.rb') diff --git a/test/util/autoload.rb b/test/util/autoload.rb index 3fe18352c..05363d13e 100755 --- a/test/util/autoload.rb +++ b/test/util/autoload.rb @@ -103,10 +103,10 @@ TestAutoload.newthing(:#{name.to_s}) assert(loader.send(:searchpath).include?(dir), "searchpath does not include the libdir") end - # This causes very strange behaviour in the tests. We need to make sure we - # require the same path that a user would use, otherwise we'll result in - # a reload of the - def test_require_does_not_cause_reload + # This tests #1064, which was caused by using the unqualified + # path for requires, which was initially done so that the kernel + # would keep track of which files got loaded. + def test_require_uses_full_path loadname = "testing" loader = Puppet::Util::Autoload.new(self.class, loadname) @@ -120,7 +120,7 @@ TestAutoload.newthing(:#{name.to_s}) Dir.expects(:glob).with("#{dir}/*.rb").returns(file) - Kernel.expects(:require).with(File.join(loadname, subname)) + Kernel.expects(:require).with(file) loader.loadall end -- cgit From c4f7c5180009ff8e8d7cb9d8a286a916991b7c1b Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 13 Feb 2008 17:30:18 -0600 Subject: Fixing comment -- ticket #1027 instead of #1064 --- test/util/autoload.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/util/autoload.rb') diff --git a/test/util/autoload.rb b/test/util/autoload.rb index 05363d13e..de503ab99 100755 --- a/test/util/autoload.rb +++ b/test/util/autoload.rb @@ -103,7 +103,7 @@ TestAutoload.newthing(:#{name.to_s}) assert(loader.send(:searchpath).include?(dir), "searchpath does not include the libdir") end - # This tests #1064, which was caused by using the unqualified + # This tests #1027, which was caused by using the unqualified # path for requires, which was initially done so that the kernel # would keep track of which files got loaded. def test_require_uses_full_path -- cgit