summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-02-13 16:52:26 -0600
committerLuke Kanies <luke@madstop.com>2008-02-13 16:52:26 -0600
commitf8afe131699f1f0afe834b070af285fd56f6320d (patch)
tree7f3c5db91aeefaaaf4ffeb3efdaa80f6efe995fb /test
parentfe02591eaad7c8648699b53c9361ffab851e2022 (diff)
downloadpuppet-f8afe131699f1f0afe834b070af285fd56f6320d.tar.gz
puppet-f8afe131699f1f0afe834b070af285fd56f6320d.tar.xz
puppet-f8afe131699f1f0afe834b070af285fd56f6320d.zip
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.
Diffstat (limited to 'test')
-rwxr-xr-xtest/lib/puppettest.rb2
-rwxr-xr-xtest/util/autoload.rb19
2 files changed, 21 insertions, 0 deletions
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 64cb7aebe..902831e68 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -17,6 +17,8 @@ Dir["#{mainlib}/../vendor/gems/**"].each do |path|
end
end
+require 'mocha'
+
# Only load the test/unit class if we're not in the spec directory.
# Else we get the bogus 'no tests, no failures' message.
unless Dir.getwd =~ /spec/
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