summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/autoload.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-05-17 17:20:55 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-05-20 18:29:04 +1000
commit415553e9485d7ba3ed867033ac9c3315107d3c92 (patch)
treeedec1c8310b21a6564b7b15a226252f29906a604 /spec/unit/util/autoload.rb
parentd489a2b9e2806beefd41627adf7e20d23b0924d6 (diff)
downloadpuppet-415553e9485d7ba3ed867033ac9c3315107d3c92.tar.gz
puppet-415553e9485d7ba3ed867033ac9c3315107d3c92.tar.xz
puppet-415553e9485d7ba3ed867033ac9c3315107d3c92.zip
Adding caching of file metadata to the autoloader
The cache isn't actually used yet - this just adds all of the plumbing. It was found that stat'ing files that didn't exist could take up to 85% of a run, so this is progress toward getting rid of those stats. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/util/autoload.rb')
-rwxr-xr-xspec/unit/util/autoload.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/spec/unit/util/autoload.rb b/spec/unit/util/autoload.rb
index 53b90db69..3bd5b50ad 100755
--- a/spec/unit/util/autoload.rb
+++ b/spec/unit/util/autoload.rb
@@ -51,6 +51,10 @@ describe Puppet::Util::Autoload do
end
end
+ it "should include its FileCache module" do
+ Puppet::Util::Autoload.ancestors.should be_include(Puppet::Util::Autoload::FileCache)
+ end
+
describe "when loading a file" do
before do
@autoload.stubs(:searchpath).returns %w{/a}
@@ -58,14 +62,20 @@ describe Puppet::Util::Autoload do
[RuntimeError, LoadError, SyntaxError].each do |error|
it "should not die an if a #{error.to_s} exception is thrown" do
- FileTest.stubs(:directory?).returns true
- FileTest.stubs(:exist?).returns true
+ @autoload.stubs(:file_exist?).returns true
Kernel.expects(:load).raises error
@autoload.load("foo")
end
end
+
+ it "should skip files that it knows are missing" do
+ @autoload.expects(:missing_file?).returns true
+ @autoload.expects(:eachdir).never
+
+ @autoload.load("foo")
+ end
end
describe "when loading all files" do