summaryrefslogtreecommitdiffstats
path: root/test/util/autoload.rb
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-02-14 11:24:39 +1100
committerJames Turnbull <james@lovedthanlost.net>2008-02-14 11:24:39 +1100
commit95db7702b162615c04a138c5e3a266f3d1dcf36c (patch)
treedea820d409a2d165f36d58799be4a73ec5934534 /test/util/autoload.rb
parentc0d72265a37bffbb0becee0c46511db2a1108899 (diff)
parent5ef8a3e6eb81c7367f50c9de3ec10a8301b106d1 (diff)
downloadpuppet-95db7702b162615c04a138c5e3a266f3d1dcf36c.tar.gz
puppet-95db7702b162615c04a138c5e3a266f3d1dcf36c.tar.xz
puppet-95db7702b162615c04a138c5e3a266f3d1dcf36c.zip
Merge branch '0.24.x' of git://reductivelabs.com/puppet into 0.24.x
Diffstat (limited to 'test/util/autoload.rb')
-rwxr-xr-xtest/util/autoload.rb29
1 files changed, 24 insertions, 5 deletions
diff --git a/test/util/autoload.rb b/test/util/autoload.rb
index 6babed774..de503ab99 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 #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
loadname = "testing"
loader = Puppet::Util::Autoload.new(self.class, loadname)
@@ -120,7 +120,26 @@ 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
+
+ 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