Previously any changed file got loaded; now we only try to load files that are still present.
Signed-off-by: Luke Kanies <[email protected]> --- lib/puppet/configurer/plugin_handler.rb | 1 + spec/unit/configurer/plugin_handler.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/lib/puppet/configurer/plugin_handler.rb b/lib/puppet/configurer/plugin_handler.rb index def6a17..e934f58 100644 --- a/lib/puppet/configurer/plugin_handler.rb +++ b/lib/puppet/configurer/plugin_handler.rb @@ -13,6 +13,7 @@ module Puppet::Configurer::PluginHandler end def load_plugin(file) + return unless FileTest.exist?(file) return if FileTest.directory?(file) begin diff --git a/spec/unit/configurer/plugin_handler.rb b/spec/unit/configurer/plugin_handler.rb index 7baece9..7f59d5b 100755 --- a/spec/unit/configurer/plugin_handler.rb +++ b/spec/unit/configurer/plugin_handler.rb @@ -57,6 +57,7 @@ describe Puppet::Configurer::PluginHandler do end it "should load each downloaded file" do + FileTest.stubs(:exist?).returns true downloader = mock 'downloader' Puppet::Configurer::Downloader.expects(:new).returns downloader @@ -72,12 +73,21 @@ describe Puppet::Configurer::PluginHandler do end it "should load plugins when asked to do so" do + FileTest.stubs(:exist?).returns true @pluginhandler.expects(:load).with("foo") @pluginhandler.load_plugin("foo") end + it "should not try to load files that don't exist" do + FileTest.expects(:exist?).with("foo").returns true + @pluginhandler.expects(:load).never + + @pluginhandler.load_plugin("foo") + end + it "should not try to load directories" do + FileTest.stubs(:exist?).returns true FileTest.expects(:directory?).with("foo").returns true @pluginhandler.expects(:load).never @@ -85,6 +95,7 @@ describe Puppet::Configurer::PluginHandler do end it "should warn but not fail if loading a file raises an exception" do + FileTest.stubs(:exist?).returns true @pluginhandler.expects(:load).with("foo").raises "eh" Puppet.expects(:err) @@ -92,6 +103,7 @@ describe Puppet::Configurer::PluginHandler do end it "should warn but not fail if loading a file raises a LoadError" do + FileTest.stubs(:exist?).returns true @pluginhandler.expects(:load).with("foo").raises LoadError.new("eh") Puppet.expects(:err) -- 1.6.1 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---
