summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG2
-rw-r--r--lib/puppet/parser/parser_support.rb8
-rwxr-xr-xtest/language/parser.rb9
3 files changed, 16 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 2e1a3d709..2e57e5f32 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+ Fixed #1184 -- definitions now autoload correctly all of the time.
+
Removed the code from the client that tries to avoid recompiling
the catalog. The client will now always recompile, assuming it
can reach the server. It will still use the cached config if
diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb
index b86a4792b..d70722fdd 100644
--- a/lib/puppet/parser/parser_support.rb
+++ b/lib/puppet/parser/parser_support.rb
@@ -237,7 +237,9 @@ class Puppet::Parser::Parser
end
end
- return true if classes.include?(classname)
+ # We don't know whether we're looking for a class or definition, so we have
+ # to test for both.
+ return true if classes.include?(classname) || definitions.include?(classname)
unless @loaded.include?(filename)
@loaded << filename
@@ -249,7 +251,9 @@ class Puppet::Parser::Parser
# We couldn't load the file
end
end
- return classes.include?(classname)
+ # We don't know whether we're looking for a class or definition, so we have
+ # to test for both.
+ return classes.include?(classname) || definitions.include?(classname)
end
# Split an fq name into a namespace and name
diff --git a/test/language/parser.rb b/test/language/parser.rb
index 2161a33f5..cdd13297a 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -1141,7 +1141,6 @@ file { "/tmp/yayness":
name = "sub"
mk_module(modname, :init => %w{separate}, :sub => %w{separate::sub})
- Puppet.err :yay
# First try it with a namespace
klass = parser.findclass("separate", name)
assert_instance_of(AST::HostClass, klass, "Did not autoload sub class from separate file with a namespace")
@@ -1171,6 +1170,14 @@ file { "/tmp/yayness":
klass = parser.findclass("", "alone::sub")
assert_instance_of(AST::HostClass, klass, "Did not autoload sub class from alone file with no namespace")
assert_equal("alone::sub", klass.classname, "Incorrect class was returned")
+
+ # and with the definition in its own file
+ name = "mymod"
+ mk_module(name, :define => true, :mydefine => ["mymod::mydefine"])
+
+ klass = parser.finddefine("", "mymod::mydefine")
+ assert_instance_of(AST::Definition, klass, "Did not autoload definition from its own file")
+ assert_equal("mymod::mydefine", klass.classname, "Incorrect definition was returned")
end
# Make sure class, node, and define methods are case-insensitive