summaryrefslogtreecommitdiffstats
path: root/test/util/autoload.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-03 19:36:35 -0500
committerLuke Kanies <luke@madstop.com>2007-10-03 19:36:35 -0500
commitbb3b3cedf4082dc884e41b864fa755057d20e228 (patch)
tree320cbf4056597adf7edb69d0f7442437d729cc77 /test/util/autoload.rb
parent782bc4d3b037684f472e1db53c1878390b8c9a32 (diff)
downloadpuppet-bb3b3cedf4082dc884e41b864fa755057d20e228.tar.gz
puppet-bb3b3cedf4082dc884e41b864fa755057d20e228.tar.xz
puppet-bb3b3cedf4082dc884e41b864fa755057d20e228.zip
I finally tracked down the problem that was causing providers
to sometimes suddenly disappear and thus tests to fail -- Kernel.require was not loading the normal ruby path (e.g., 'puppet/type/cron'), so if someone else loaded that then it would replace the in-memory type with a new one, but that new one couldn't load its own providers, because the Kernel would ignore the providers, thinking they were already loaded. This doesn't fix all of the autoloading problems, but at least we won't suddenly break a ton of tests.
Diffstat (limited to 'test/util/autoload.rb')
-rwxr-xr-xtest/util/autoload.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/util/autoload.rb b/test/util/autoload.rb
index bae6d37d4..ca77572c2 100755
--- a/test/util/autoload.rb
+++ b/test/util/autoload.rb
@@ -102,4 +102,25 @@ 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
+ loadname = "testing"
+ loader = Puppet::Util::Autoload.new(self.class, loadname)
+
+ basedir = "/some/dir"
+ dir = File.join(basedir, loadname)
+ loader.expects(:eachdir).yields(dir)
+
+ subname = "instance"
+
+ file = File.join(dir, subname) + ".rb"
+
+ Dir.expects(:glob).with("#{dir}/*.rb").returns(file)
+
+ Kernel.expects(:require).with(File.join(loadname, subname))
+ loader.loadall
+ end
end