From 0e336bf62b818aaa31fcc323ab5d31e5eb92eb46 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 5 Oct 2007 00:07:38 -0500 Subject: This commit is focused on getting the 'puppet' executable to work. As a result, it involves a lot of integration-level testing, and a lot of small design changes to make the code actually work. In particular, indirections can now have default termini, so that configurations and facts default to their code terminus Also, I've removed the ability to manually control whether ast nodes are used. I might need to add it back in later, but if so it will be in the form of a global setting, rather than the previous system of passing it through 10 different classes. Instead, the parser detects whether there are AST nodes defined and requires them if so or ignores them if not. About 75 tests are still failing in the main set of tests, but it's going to be a long slog to get them working -- there are significant design issues around them, as most of the failures are a result of tests trying to emulate both the client and server sides of a connection, which normally would have different fact termini but in this case must have the same terminus just because they're in the same process and are global. The next step, then, is to figure that process out, thus finding a way to make this all work. --- lib/puppet/parser/compile.rb | 4 +--- lib/puppet/parser/interpreter.rb | 7 +------ 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/compile.rb b/lib/puppet/parser/compile.rb index 6aeebeaae..992b165e5 100644 --- a/lib/puppet/parser/compile.rb +++ b/lib/puppet/parser/compile.rb @@ -16,8 +16,6 @@ class Puppet::Parser::Compile include Puppet::Util::Errors attr_reader :topscope, :parser, :node, :facts, :collections, :configuration - attr_writer :ast_nodes - # Add a collection to the global list. def add_collection(coll) @collections << coll @@ -25,7 +23,7 @@ class Puppet::Parser::Compile # Do we use nodes found in the code, vs. the external node sources? def ast_nodes? - defined?(@ast_nodes) and @ast_nodes + parser.nodes.length > 0 end # Store the fact that we've evaluated a class, and store a reference to diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index 0b8c035ba..8c727118c 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -26,7 +26,7 @@ class Puppet::Parser::Interpreter # evaluate our whole tree def compile(node) raise Puppet::ParseError, "Could not parse configuration; cannot compile" unless env_parser = parser(node.environment) - return Puppet::Parser::Compile.new(node, env_parser, :ast_nodes => usenodes?).compile + return Puppet::Parser::Compile.new(node, env_parser).compile end # create our interpreter @@ -53,11 +53,6 @@ class Puppet::Parser::Interpreter @parsers = {} end - # Should we parse ast nodes? - def usenodes? - defined?(@usenodes) and @usenodes - end - private # Create a new parser object and pre-parse the configuration. -- cgit From 9c58c476c2ffcf9613f14e5881b1177f01d413a7 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 5 Oct 2007 11:46:35 -0500 Subject: Adding a :code setting for specifying code to run instead of a manifest, and removing all of the ambiguity around whether an interpreter gets its own file specified or uses the central setting. Most of the changes are around fixing existing tests to use this new system. --- lib/puppet/parser/interpreter.rb | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index 8c727118c..87513cb18 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -14,7 +14,6 @@ class Puppet::Parser::Interpreter include Puppet::Util attr_accessor :usenodes - attr_accessor :code, :file include Puppet::Util::Errors @@ -30,17 +29,7 @@ class Puppet::Parser::Interpreter end # create our interpreter - def initialize(options = {}) - if @code = options[:Code] - elsif @file = options[:Manifest] - end - - if options.include?(:UseNodes) - @usenodes = options[:UseNodes] - else - @usenodes = true - end - + def initialize # The class won't always be defined during testing. if Puppet[:storeconfigs] if Puppet.features.rails? @@ -59,10 +48,8 @@ class Puppet::Parser::Interpreter def create_parser(environment) begin parser = Puppet::Parser::Parser.new(:environment => environment) - if self.code - parser.string = self.code - elsif self.file - parser.file = self.file + if code = Puppet.settings.value(:code, environment) and code != "" + parser.string = code else file = Puppet.settings.value(:manifest, environment) parser.file = file -- cgit From cdaad286b1fe5fc3c1ab363c890bb6a8a752c9b5 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 5 Oct 2007 17:46:30 -0500 Subject: Fixing error thrown when the end of the file is encountered unexpectedly --- lib/puppet/parser/parser_support.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index 8cf0dcfe8..acf3c9f7c 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -366,10 +366,12 @@ class Puppet::Parser::Parser end def on_error(token,value,stack) - #on '%s' at '%s' in\n'%s'" % [token,value,stack] - #error = "line %s: parse error after '%s'" % - # [@lexer.line,@lexer.last] - error = "Syntax error at '%s'" % [value] + if token == 0 # denotes end of file + value = 'end of file' + else + value = "'%s'" % value + end + error = "Syntax error at %s" % [value] if brace = @lexer.expected error += "; expected '%s'" % brace -- cgit