diff options
-rw-r--r-- | lib/puppet/error.rb | 6 | ||||
-rw-r--r-- | lib/puppet/parser/functions.rb | 20 | ||||
-rw-r--r-- | lib/puppet/parser/grammar.ra | 4 | ||||
-rw-r--r-- | lib/puppet/parser/interpreter.rb | 15 | ||||
-rw-r--r-- | lib/puppet/parser/parser.rb | 8 | ||||
-rwxr-xr-x | test/language/functions.rb | 7 |
6 files changed, 41 insertions, 19 deletions
diff --git a/lib/puppet/error.rb b/lib/puppet/error.rb index b70a4dddf..10ccf47be 100644 --- a/lib/puppet/error.rb +++ b/lib/puppet/error.rb @@ -22,12 +22,14 @@ module Puppet # :nodoc: def to_s str = nil - if defined? @file and defined? @line and @file and @line + if self.file and self.line str = "%s at %s:%s" % [@message.to_s, @file, @line] - elsif defined? @line and @line + elsif self.line str = "%s at line %s" % [@message.to_s, @line] + elsif self.file + str = "%s in %s" % [@message.to_s, self.file] else str = @message.to_s end diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index b02ea4308..1f9c8f519 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -113,13 +113,19 @@ module Functions ! klasses.include?(klass) end - # Throw an error if we didn't evaluate all of the classes. - if missing.length == 1 - self.fail Puppet::ParseError, - "Could not find class %s" % missing - elsif missing.length > 1 - self.fail Puppet::ParseError, - "Could not find classes %s" % missing.join(", ") + unless missing.empty? + # Throw an error if we didn't evaluate all of the classes. + str = "Could not find class" + if missing.length > 1 + str += "es" + end + + str += " " + missing.join(", ") + + if n = namespaces and ! n.empty? and n != [""] + str += " in namespaces %s" % @namespaces.join(", ") + end + self.fail Puppet::ParseError, str end end diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra index b76e8c314..6bca6495e 100644 --- a/lib/puppet/parser/grammar.ra +++ b/lib/puppet/parser/grammar.ra @@ -635,11 +635,11 @@ end # available. def ast(klass, hash = nil) hash ||= {} - unless hash[:line] + unless hash.include?(:line) hash[:line] = @lexer.line end - unless hash[:file] + unless hash.include?(:file) if file = @lexer.file hash[:file] = file end diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index 5eb44c39c..936bc31eb 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -314,7 +314,7 @@ class Puppet::Parser::Interpreter end # Create a new node, just from a list of names, classes, and an optional parent. - def gennode(name, hash) + def gennode(name, hash, source = nil) facts = hash[:facts] classes = hash[:classes] parent = hash[:parentnode] @@ -348,7 +348,14 @@ class Puppet::Parser::Interpreter end # Create the node - return @parser.ast(AST::Node, arghash) + if source + arghash[:file] = source + else + arghash[:file] = nil + end + arghash[:line] = nil + node = @parser.ast(AST::Node, arghash) + return node end # create our interpreter @@ -716,7 +723,7 @@ class Puppet::Parser::Interpreter Puppet.warning "Somehow got a node with no information" return nil else - return gennode(name, args) + return gennode(name, args, Puppet[:external_nodes]) end end @@ -727,7 +734,7 @@ class Puppet::Parser::Interpreter args = {} args[:classes] = classes if classes args[:parentnode] = parent if parent - return gennode(node, args) + return gennode(node, args, "ldap") else return nil end diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb index a4c2da63e..8b75200b5 100644 --- a/lib/puppet/parser/parser.rb +++ b/lib/puppet/parser/parser.rb @@ -29,7 +29,7 @@ module Puppet class Parser < Racc::Parser -module_eval <<'..end grammar.ra modeval..id729500608d', 'grammar.ra', 603 +module_eval <<'..end grammar.ra modeval..idde6e0009a9', 'grammar.ra', 603 require 'puppet/parser/functions' attr_reader :file, :interp @@ -65,11 +65,11 @@ end # available. def ast(klass, hash = nil) hash ||= {} - unless hash[:line] + unless hash.include?(:line) hash[:line] = @lexer.line end - unless hash[:file] + unless hash.include?(:file) if file = @lexer.file hash[:file] = file end @@ -254,7 +254,7 @@ end # $Id$ -..end grammar.ra modeval..id729500608d +..end grammar.ra modeval..idde6e0009a9 ##### racc 1.4.5 generates ### diff --git a/test/language/functions.rb b/test/language/functions.rb index ad6aa2761..2d882382d 100755 --- a/test/language/functions.rb +++ b/test/language/functions.rb @@ -444,6 +444,13 @@ class TestLangFunctions < Test::Unit::TestCase assert(scope.classlist.include?(c), "class %s was not evaluated" % c) end + + # Now try a scoped class + interp.newclass("os::redhat") + + assert_nothing_raised("Could not include qualified class name") do + scope.function_include("os::redhat") + end end def test_file |