diff options
author | Luke Kanies <luke@madstop.com> | 2009-05-17 17:10:16 -0500 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-05-20 18:29:04 +1000 |
commit | d489a2b9e2806beefd41627adf7e20d23b0924d6 (patch) | |
tree | afdfa61e1bd6d2704826467abb5b022050494684 /test/util/autoload.rb | |
parent | 5f1c228767432591a7e4b77666e9b1c7d70a095c (diff) | |
download | puppet-d489a2b9e2806beefd41627adf7e20d23b0924d6.tar.gz puppet-d489a2b9e2806beefd41627adf7e20d23b0924d6.tar.xz puppet-d489a2b9e2806beefd41627adf7e20d23b0924d6.zip |
Adding modulepath caching to the Autoloader
There's more caching to add, but this simplifies
the interface to the list of paths and then caches
that list so we aren't constantly searching the
filesystem.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'test/util/autoload.rb')
-rwxr-xr-x | test/util/autoload.rb | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/test/util/autoload.rb b/test/util/autoload.rb index de503ab99..6aaf32995 100755 --- a/test/util/autoload.rb +++ b/test/util/autoload.rb @@ -93,16 +93,6 @@ TestAutoload.newthing(:#{name.to_s}) end end - # Make sure that autoload dynamically modifies $: with the libdir as - # appropriate. - def test_searchpath - dir = Puppet[:libdir] - - loader = Puppet::Util::Autoload.new(self, "testing") - - assert(loader.send(:searchpath).include?(dir), "searchpath does not include the libdir") - end - # 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. @@ -112,7 +102,7 @@ TestAutoload.newthing(:#{name.to_s}) basedir = "/some/dir" dir = File.join(basedir, loadname) - loader.expects(:eachdir).yields(dir) + loader.expects(:searchpath).returns(dir) subname = "instance" @@ -123,23 +113,4 @@ TestAutoload.newthing(:#{name.to_s}) Kernel.expects(:require).with(file) 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 |