summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/metatype/providers.rb5
-rw-r--r--lib/puppet/parser/collector.rb4
-rw-r--r--lib/puppet/util/autoload.rb25
-rwxr-xr-xtest/language/ast/definition.rb2
-rwxr-xr-xtest/language/parser.rb2
-rwxr-xr-xtest/language/resource.rb4
-rwxr-xr-xtest/language/scope.rb10
-rwxr-xr-xtest/util/autoload.rb27
8 files changed, 25 insertions, 54 deletions
diff --git a/lib/puppet/metatype/providers.rb b/lib/puppet/metatype/providers.rb
index 8210dd382..c302d9928 100644
--- a/lib/puppet/metatype/providers.rb
+++ b/lib/puppet/metatype/providers.rb
@@ -230,6 +230,9 @@ class Puppet::Type
# Return an array of all of the suitable providers.
def self.suitableprovider
+ if @providers.empty?
+ providerloader.loadall
+ end
@providers.find_all { |name, provider|
provider.suitable?
}.collect { |name, provider|
@@ -249,5 +252,3 @@ class Puppet::Type
end
end
end
-
-# $Id$
diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb
index d995bf7a7..3eb37dfa2 100644
--- a/lib/puppet/parser/collector.rb
+++ b/lib/puppet/parser/collector.rb
@@ -121,10 +121,6 @@ class Puppet::Parser::Collector
def initialize(scope, type, equery, vquery, form)
@scope = scope
-
- unless scope.resource
- raise "wtf?"
- end
@type = type
@equery = equery
@vquery = vquery
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb
index 65cd3affb..280961837 100644
--- a/lib/puppet/util/autoload.rb
+++ b/lib/puppet/util/autoload.rb
@@ -3,7 +3,7 @@ class Puppet::Util::Autoload
include Puppet::Util
@autoloaders = {}
- @loaded = {}
+ @loaded = []
class << self
attr_reader :autoloaders
@@ -13,12 +13,6 @@ class Puppet::Util::Autoload
# Send [], []=, and :clear to the @autloaders hash
Puppet::Util.classproxy self, :autoloaders, "[]", "[]="
- # Clear the list of autoloaders and loaded files.
- def self.clear
- @autoloaders.clear
- @loaded.clear
- end
-
# List all loaded files.
def self.list_loaded
@loaded.sort { |a,b| a[0] <=> b[0] }.collect do |path, hash|
@@ -27,15 +21,20 @@ class Puppet::Util::Autoload
end
# Has a given path been loaded? This is used for testing whether a
- # changed file should be loaded or just ignored.
+ # changed file should be loaded or just ignored. This is only
+ # used in network/client/master, when downloading plugins, to
+ # see if a given plugin is currently loaded and thus should be
+ # reloaded.
def self.loaded?(path)
path = path.to_s.sub(/\.rb$/, '')
- @loaded[path]
+ @loaded.include?(path)
end
- # Save the fact that a given path has been loaded
- def self.loaded(path, file, loader)
- @loaded[path] = {:file => file, :autoloader => loader}
+ # Save the fact that a given path has been loaded. This is so
+ # we can load downloaded plugins if they've already been loaded
+ # into memory.
+ def self.loaded(file)
+ @loaded << file unless @loaded.include?(file)
end
attr_accessor :object, :path, :objwarn, :wrap
@@ -94,7 +93,7 @@ class Puppet::Util::Autoload
# Mark the named object as loaded. Note that this supports unqualified
# queries, while we store the result as a qualified query in the class.
def loaded(name, file)
- self.class.loaded(File.join(@path, name.to_s), file, object)
+ self.class.loaded(File.join(@path, name.to_s))
end
# Indicate whether the specfied plugin has been loaded.
diff --git a/test/language/ast/definition.rb b/test/language/ast/definition.rb
index 7db5d2849..d4c987362 100755
--- a/test/language/ast/definition.rb
+++ b/test/language/ast/definition.rb
@@ -40,7 +40,7 @@ class TestASTDefinition < Test::Unit::TestCase
def test_evaluate
parser = mkparser
- config = mkconfig
+ config = mkcompile
config.send(:evaluate_main)
scope = config.topscope
klass = parser.newdefine "yayness",
diff --git a/test/language/parser.rb b/test/language/parser.rb
index d50bdfe5a..1cef72dcb 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -42,7 +42,7 @@ class TestParser < Test::Unit::TestCase
assert_raise(Puppet::ParseError, "Did not fail while parsing %s" % file) {
parser.file = file
ast = parser.parse
- config = mkconfig(parser)
+ config = mkcompile(parser)
config.compile
#ast.classes[""].evaluate :scope => config.topscope
}
diff --git a/test/language/resource.rb b/test/language/resource.rb
index 8978a3a37..f25be93b5 100755
--- a/test/language/resource.rb
+++ b/test/language/resource.rb
@@ -392,7 +392,7 @@ class TestResource < PuppetTest::TestCase
{:name => "one", :title => "two"},
{:title => "three"},
].each do |hash|
- config = mkconfig parser
+ config = mkcompile parser
args = {:type => "yayness", :title => hash[:title],
:source => klass, :scope => config.topscope}
if hash[:name]
@@ -439,7 +439,7 @@ class TestResource < PuppetTest::TestCase
:code => resourcedef("file", varref("name"),
"mode" => "644"))
- config = mkconfig(parser)
+ config = mkcompile(parser)
res = mkresource :type => "yayness", :title => "foo", :params => {}, :scope => config.topscope
res.virtual = true
diff --git a/test/language/scope.rb b/test/language/scope.rb
index b317fa4c8..74f47b136 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -27,7 +27,7 @@ class TestScope < Test::Unit::TestCase
end
def test_variables
- config = mkconfig
+ config = mkcompile
topscope = config.topscope
midscope = config.newscope(topscope)
botscope = config.newscope(midscope)
@@ -125,7 +125,7 @@ class TestScope < Test::Unit::TestCase
end
def test_setdefaults
- config = mkconfig
+ config = mkcompile
scope = config.topscope
@@ -151,7 +151,7 @@ class TestScope < Test::Unit::TestCase
end
def test_lookupdefaults
- config = mkconfig
+ config = mkcompile
top = config.topscope
# Make a subscope
@@ -179,7 +179,7 @@ class TestScope < Test::Unit::TestCase
end
def test_parent
- config = mkconfig
+ config = mkcompile
top = config.topscope
# Make a subscope
@@ -332,7 +332,7 @@ class TestScope < Test::Unit::TestCase
# Verify that we recursively mark as exported the results of collectable
# components.
def test_exportedcomponents
- config = mkconfig
+ config = mkcompile
parser = config.parser
# Create a default source
diff --git a/test/util/autoload.rb b/test/util/autoload.rb
index 493fd7f60..bae6d37d4 100755
--- a/test/util/autoload.rb
+++ b/test/util/autoload.rb
@@ -50,11 +50,6 @@ TestAutoload.newthing(:#{name.to_s})
return rbdir, loader
end
- def teardown
- super
- Puppet::Util::Autoload.clear
- end
-
def test_load
dir, loader = mk_loader(:yayness)
@@ -84,36 +79,18 @@ TestAutoload.newthing(:#{name.to_s})
assert(self.class.thing?(:mything),
"Did not get loaded thing")
- # Now clear everything, and test loadall
- assert_nothing_raised {
- Puppet::Util::Autoload.clear
- }
-
self.class.clear
- assert_nothing_raised {
- loader.loadall
- }
-
[:mything, :othing].each do |thing|
+ loader.load(thing)
assert(loader.loaded?(thing), "#{thing.to_s} not considered loaded")
assert(loader.loaded?("%s.rb" % thing), "#{thing.to_s} not considered loaded with .rb")
assert(Puppet::Util::Autoload.loaded?("yayness/%s" % thing), "%s not considered loaded by the main class" % thing)
assert(Puppet::Util::Autoload.loaded?("yayness/%s.rb" % thing), "%s not considered loaded by the main class with .rb" % thing)
- loaded = Puppet::Util::Autoload.loaded?("yayness/%s.rb" % thing)
- assert_equal("%s/%s.rb" % [dir, thing], loaded[:file], "File path was not set correctly in loaded store")
- assert_equal(self.class, loaded[:autoloader], "Loader was not set correctly in loaded store")
-
assert(self.class.thing?(thing),
"Did not get loaded #{thing.to_s}")
end
-
- Puppet::Util::Autoload.clear
- [:mything, :othing].each do |thing|
- assert(! loader.loaded?(thing), "#{thing.to_s} considered loaded after clear")
- assert(! Puppet::Util::Autoload.loaded?("yayness/%s" % thing), "%s considered loaded by the main class after clear" % thing)
- end
end
# Make sure that autoload dynamically modifies $: with the libdir as
@@ -126,5 +103,3 @@ TestAutoload.newthing(:#{name.to_s})
assert(loader.send(:searchpath).include?(dir), "searchpath does not include the libdir")
end
end
-
-# $Id$