summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/parser/ast/collection.rb2
-rw-r--r--lib/puppet/parser/ast/definition.rb2
-rw-r--r--lib/puppet/parser/ast/hostclass.rb6
-rw-r--r--lib/puppet/parser/ast/node.rb2
-rw-r--r--lib/puppet/parser/ast/resource.rb4
-rw-r--r--lib/puppet/parser/ast/resource_override.rb2
-rw-r--r--lib/puppet/parser/collector.rb8
-rw-r--r--lib/puppet/parser/compiler.rb (renamed from lib/puppet/parser/compile.rb)10
-rw-r--r--lib/puppet/parser/functions.rb6
-rw-r--r--lib/puppet/parser/interpreter.rb4
-rw-r--r--lib/puppet/parser/scope.rb16
-rw-r--r--lib/puppet/parser/templatewrapper.rb2
-rwxr-xr-xspec/unit/node/catalog.rb6
-rwxr-xr-xspec/unit/parser/ast/definition.rb4
-rwxr-xr-xspec/unit/parser/ast/hostclass.rb24
-rwxr-xr-xspec/unit/parser/collector.rb60
-rwxr-xr-xspec/unit/parser/compiler.rb (renamed from spec/unit/parser/compile.rb)266
-rwxr-xr-xspec/unit/parser/interpreter.rb6
-rwxr-xr-xspec/unit/parser/resource.rb8
-rwxr-xr-xspec/unit/parser/resource/reference.rb8
-rwxr-xr-xtest/language/ast.rb4
-rwxr-xr-xtest/language/ast/definition.rb2
-rwxr-xr-xtest/language/ast/node.rb2
-rwxr-xr-xtest/language/ast/resource.rb2
-rwxr-xr-xtest/language/ast/resource_reference.rb2
-rwxr-xr-xtest/language/functions.rb26
-rwxr-xr-xtest/language/parser.rb4
-rwxr-xr-xtest/language/resource.rb4
-rwxr-xr-xtest/language/scope.rb18
-rw-r--r--test/lib/puppettest/parsertesting.rb16
30 files changed, 263 insertions, 263 deletions
diff --git a/lib/puppet/parser/ast/collection.rb b/lib/puppet/parser/ast/collection.rb
index 31f508929..9e795a33c 100644
--- a/lib/puppet/parser/ast/collection.rb
+++ b/lib/puppet/parser/ast/collection.rb
@@ -18,7 +18,7 @@ class Collection < AST::Branch
newcoll = Puppet::Parser::Collector.new(scope, @type, str, code, self.form)
- scope.compile.add_collection(newcoll)
+ scope.compiler.add_collection(newcoll)
newcoll
end
diff --git a/lib/puppet/parser/ast/definition.rb b/lib/puppet/parser/ast/definition.rb
index 992bb1f5e..b4a90016a 100644
--- a/lib/puppet/parser/ast/definition.rb
+++ b/lib/puppet/parser/ast/definition.rb
@@ -31,7 +31,7 @@ class Puppet::Parser::AST::Definition < Puppet::Parser::AST::Branch
scope.catalog.tag(*resource.tags)
- scope.compile.add_resource(scope, resource)
+ scope.compiler.add_resource(scope, resource)
return resource
end
diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb
index 4f2d00f0c..f49016526 100644
--- a/lib/puppet/parser/ast/hostclass.rb
+++ b/lib/puppet/parser/ast/hostclass.rb
@@ -32,7 +32,7 @@ class Puppet::Parser::AST::HostClass < Puppet::Parser::AST::Definition
scope = resource.scope
# Verify that we haven't already been evaluated. This is
# what provides the singleton aspect.
- if existing_scope = scope.compile.class_scope(self)
+ if existing_scope = scope.compiler.class_scope(self)
Puppet.debug "Class '%s' already evaluated; not evaluating again" % (classname == "" ? "main" : classname)
return nil
end
@@ -57,7 +57,7 @@ class Puppet::Parser::AST::HostClass < Puppet::Parser::AST::Definition
# Set the class before we do anything else, so that it's set
# during the evaluation and can be inspected.
- scope.compile.class_set(self.classname, scope)
+ scope.compiler.class_set(self.classname, scope)
# Now evaluate our code, yo.
if self.code
@@ -68,7 +68,7 @@ class Puppet::Parser::AST::HostClass < Puppet::Parser::AST::Definition
end
def parent_scope(scope, klass)
- if s = scope.compile.class_scope(klass)
+ if s = scope.compiler.class_scope(klass)
return s
else
raise Puppet::DevError, "Could not find scope for %s" % klass.classname
diff --git a/lib/puppet/parser/ast/node.rb b/lib/puppet/parser/ast/node.rb
index 7ff7a18e1..8cebac8a8 100644
--- a/lib/puppet/parser/ast/node.rb
+++ b/lib/puppet/parser/ast/node.rb
@@ -25,7 +25,7 @@ class Puppet::Parser::AST::Node < Puppet::Parser::AST::HostClass
# Mark our node name as a class, too, but strip it of the domain
# name. Make the mark before we evaluate the code, so that it is
# marked within the code itself.
- scope.compile.class_set(self.classname, scope)
+ scope.compiler.class_set(self.classname, scope)
# And then evaluate our code if we have any
@code.safeevaluate(scope) if self.code
diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb
index 2dadf9ed6..8a60522a3 100644
--- a/lib/puppet/parser/ast/resource.rb
+++ b/lib/puppet/parser/ast/resource.rb
@@ -48,10 +48,10 @@ class Resource < AST::ResourceReference
:scope => scope
)
- # And then store the resource in the compile.
+ # And then store the resource in the compiler.
# At some point, we need to switch all of this to return
# objects instead of storing them like this.
- scope.compile.add_resource(scope, obj)
+ scope.compiler.add_resource(scope, obj)
obj
end
}.reject { |obj| obj.nil? }
diff --git a/lib/puppet/parser/ast/resource_override.rb b/lib/puppet/parser/ast/resource_override.rb
index db0986a8e..f9464acda 100644
--- a/lib/puppet/parser/ast/resource_override.rb
+++ b/lib/puppet/parser/ast/resource_override.rb
@@ -42,7 +42,7 @@ class Puppet::Parser::AST
# Now we tell the scope that it's an override, and it behaves as
# necessary.
- scope.compile.add_override(obj)
+ scope.compiler.add_override(obj)
obj
end
diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb
index efd64a320..e0c37cd35 100644
--- a/lib/puppet/parser/collector.rb
+++ b/lib/puppet/parser/collector.rb
@@ -118,20 +118,20 @@ class Puppet::Parser::Collector
# If there are no more resources to find, delete this from the list
# of collections.
if @resources.empty?
- @scope.compile.delete_collection(self)
+ @scope.compiler.delete_collection(self)
end
return result
end
- # Collect just virtual objects, from our local compile.
+ # Collect just virtual objects, from our local compiler.
def collect_virtual(exported = false)
if exported
method = :exported?
else
method = :virtual?
end
- scope.compile.resources.find_all do |resource|
+ scope.compiler.resources.find_all do |resource|
resource.type == @type and resource.send(method) and match?(resource)
end
end
@@ -150,7 +150,7 @@ class Puppet::Parser::Collector
resource.exported = false
- scope.compile.add_resource(scope, resource)
+ scope.compiler.add_resource(scope, resource)
return resource
end
diff --git a/lib/puppet/parser/compile.rb b/lib/puppet/parser/compiler.rb
index 2415fd5e8..27860487a 100644
--- a/lib/puppet/parser/compile.rb
+++ b/lib/puppet/parser/compiler.rb
@@ -7,7 +7,7 @@ require 'puppet/util/errors'
# Maintain a graph of scopes, along with a bunch of data
# about the individual catalog we're compiling.
-class Puppet::Parser::Compile
+class Puppet::Parser::Compiler
include Puppet::Util
include Puppet::Util::Errors
attr_reader :parser, :node, :facts, :collections, :catalog, :node_scope
@@ -76,7 +76,7 @@ class Puppet::Parser::Compile
return @catalog.classes
end
- # Compile our catalog. This mostly revolves around finding and evaluating classes.
+ # Compiler our catalog. This mostly revolves around finding and evaluating classes.
# This is the main entry into our catalog.
def compile
# Set the client's parameters into the top scope.
@@ -168,7 +168,7 @@ class Puppet::Parser::Compile
begin
send(param.to_s + "=", value)
rescue NoMethodError
- raise ArgumentError, "Compile objects do not accept %s" % param
+ raise ArgumentError, "Compiler objects do not accept %s" % param
end
end
@@ -181,7 +181,7 @@ class Puppet::Parser::Compile
# its parent to the graph.
def newscope(parent, options = {})
parent ||= topscope
- options[:compile] = self
+ options[:compiler] = self
options[:parser] ||= self.parser
scope = Puppet::Parser::Scope.new(options)
@scope_graph.add_edge!(parent, scope)
@@ -382,7 +382,7 @@ class Puppet::Parser::Compile
# Initialize the top-level scope, class, and resource.
def init_main
# Create our initial scope and a resource that will evaluate main.
- @topscope = Puppet::Parser::Scope.new(:compile => self, :parser => self.parser)
+ @topscope = Puppet::Parser::Scope.new(:compiler => self, :parser => self.parser)
@scope_graph.add_vertex!(@topscope)
end
diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index 34b38b809..e0b60e161 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -111,7 +111,7 @@ module Functions
vals = [vals] unless vals.is_a?(Array)
# The 'false' disables lazy evaluation.
- klasses = compile.evaluate_classes(vals, self, false)
+ klasses = compiler.evaluate_classes(vals, self, false)
missing = vals.find_all do |klass|
! klasses.include?(klass)
@@ -146,7 +146,7 @@ module Functions
tells you whether the current container is tagged with the specified tags.
The tags are ANDed, so that all of the specified tags must be included for
the function to return true.") do |vals|
- configtags = compile.catalog.tags
+ configtags = compiler.catalog.tags
resourcetags = resource.tags
retval = true
@@ -235,7 +235,7 @@ module Functions
vals = [vals] unless vals.is_a?(Array)
coll.resources = vals
- compile.add_collection(coll)
+ compiler.add_collection(coll)
end
newfunction(:search, :doc => "Add another namespace for this class to search.
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index e29e19944..1d93193dd 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -3,7 +3,7 @@ require 'timeout'
require 'puppet/rails'
require 'puppet/util/methodhelper'
require 'puppet/parser/parser'
-require 'puppet/parser/compile'
+require 'puppet/parser/compiler'
require 'puppet/parser/scope'
# The interpreter is a very simple entry-point class that
@@ -25,7 +25,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).compile
+ return Puppet::Parser::Compiler.new(node, env_parser).compile
end
# create our interpreter
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 81d4ac71a..a6e43e7b3 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -17,20 +17,20 @@ class Puppet::Parser::Scope
include Puppet::Util::Errors
attr_accessor :parent, :level, :parser, :source, :resource
attr_accessor :base, :keyword, :nodescope
- attr_accessor :top, :translated, :compile
+ attr_accessor :top, :translated, :compiler
# A demeterific shortcut to the catalog.
def catalog
- compile.catalog
+ compiler.catalog
end
# Proxy accessors
def host
- @compile.node.name
+ @compiler.node.name
end
def interpreter
- @compile.interpreter
+ @compiler.interpreter
end
# Is the value true? This allows us to control the definition of truth
@@ -77,7 +77,7 @@ class Puppet::Parser::Scope
end
def findresource(string, name = nil)
- compile.findresource(string, name)
+ compiler.findresource(string, name)
end
# Initialize our new scope. Defaults to having no parent.
@@ -152,7 +152,7 @@ class Puppet::Parser::Scope
unless klass
raise Puppet::ParseError, "Could not find class %s" % klassname
end
- unless kscope = compile.class_scope(klass)
+ unless kscope = compiler.class_scope(klass)
raise Puppet::ParseError, "Class %s has not been evaluated so its variables cannot be referenced" % klass.classname
end
return kscope.lookupvar(shortname, usestring)
@@ -189,7 +189,7 @@ class Puppet::Parser::Scope
# Create a new scope and set these options.
def newscope(options = {})
- compile.newscope(self, options)
+ compiler.newscope(self, options)
end
# Is this class for a node? This is used to make sure that
@@ -204,7 +204,7 @@ class Puppet::Parser::Scope
# than doing lots of queries.
def parent
unless defined?(@parent)
- @parent = compile.parent(self)
+ @parent = compiler.parent(self)
end
@parent
end
diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb
index 13823d483..7a8f74156 100644
--- a/lib/puppet/parser/templatewrapper.rb
+++ b/lib/puppet/parser/templatewrapper.rb
@@ -7,7 +7,7 @@ class Puppet::Parser::TemplateWrapper
def initialize(scope, file)
@scope = scope
- @file = Puppet::Module::find_template(file, @scope.compile.environment)
+ @file = Puppet::Module::find_template(file, @scope.compiler.environment)
unless FileTest.exists?(@file)
raise Puppet::ParseError,
diff --git a/spec/unit/node/catalog.rb b/spec/unit/node/catalog.rb
index 3833890f7..93bbd0ad2 100755
--- a/spec/unit/node/catalog.rb
+++ b/spec/unit/node/catalog.rb
@@ -57,11 +57,11 @@ describe Puppet::Node::Catalog, " when extracting transobjects" do
def mkscope
@parser = Puppet::Parser::Parser.new :Code => ""
@node = Puppet::Node.new("mynode")
- @compile = Puppet::Parser::Compile.new(@node, @parser)
+ @compiler = Puppet::Parser::Compiler.new(@node, @parser)
# XXX This is ridiculous.
- @compile.send(:evaluate_main)
- @scope = @compile.topscope
+ @compiler.send(:evaluate_main)
+ @scope = @compiler.topscope
end
def mkresource(type, name)
diff --git a/spec/unit/parser/ast/definition.rb b/spec/unit/parser/ast/definition.rb
index fae2851e3..ba80894e8 100755
--- a/spec/unit/parser/ast/definition.rb
+++ b/spec/unit/parser/ast/definition.rb
@@ -12,8 +12,8 @@ describe Puppet::Parser::AST::Definition, "when evaluating" do
@source = @parser.newclass ""
@definition = @parser.newdefine "mydefine"
@node = Puppet::Node.new("yaynode")
- @compile = Puppet::Parser::Compile.new(@node, @parser)
- @scope = @compile.topscope
+ @compiler = Puppet::Parser::Compiler.new(@node, @parser)
+ @scope = @compiler.topscope
@resource = Puppet::Parser::Resource.new(:type => "mydefine", :title => "myresource", :scope => @scope, :source => @source)
end
diff --git a/spec/unit/parser/ast/hostclass.rb b/spec/unit/parser/ast/hostclass.rb
index b1e8a48ea..422861857 100755
--- a/spec/unit/parser/ast/hostclass.rb
+++ b/spec/unit/parser/ast/hostclass.rb
@@ -7,9 +7,9 @@ module HostClassTesting
@node = Puppet::Node.new "testnode"
@parser = Puppet::Parser::Parser.new :environment => "development"
@scope_resource = stub 'scope_resource', :builtin? => true
- @compile = Puppet::Parser::Compile.new(@node, @parser)
+ @compiler = Puppet::Parser::Compiler.new(@node, @parser)
- @scope = @compile.topscope
+ @scope = @compiler.topscope
end
end
@@ -24,13 +24,13 @@ describe Puppet::Parser::AST::HostClass, "when evaluating" do
it "should create a resource that references itself" do
@top.evaluate(@scope)
- @compile.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
+ @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
end
it "should evaluate the parent class if one exists" do
@middle.evaluate(@scope)
- @compile.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
+ @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
end
it "should fail to evaluate if a parent class is defined but cannot be found" do
@@ -39,32 +39,32 @@ describe Puppet::Parser::AST::HostClass, "when evaluating" do
end
it "should not create a new resource if one already exists" do
- @compile.catalog.expects(:resource).with(:class, "top").returns("something")
- @compile.catalog.expects(:add_resource).never
+ @compiler.catalog.expects(:resource).with(:class, "top").returns("something")
+ @compiler.catalog.expects(:add_resource).never
@top.evaluate(@scope)
end
it "should not create a new parent resource if one already exists and it has a parent class" do
@top.evaluate(@scope)
- top_resource = @compile.catalog.resource(:class, "top")
+ top_resource = @compiler.catalog.resource(:class, "top")
@middle.evaluate(@scope)
- @compile.catalog.resource(:class, "top").should equal(top_resource)
+ @compiler.catalog.resource(:class, "top").should equal(top_resource)
end
# #795 - tag before evaluation.
it "should tag the catalog with the resource tags when it is evaluated" do
@middle.evaluate(@scope)
- @compile.catalog.should be_tagged("middle")
+ @compiler.catalog.should be_tagged("middle")
end
it "should tag the catalog with the parent class tags when it is evaluated" do
@middle.evaluate(@scope)
- @compile.catalog.should be_tagged("top")
+ @compiler.catalog.should be_tagged("top")
end
end
@@ -117,7 +117,7 @@ describe Puppet::Parser::AST::HostClass, "when evaluating code" do
resource = @middle.evaluate(@scope)
@middle.evaluate_code(resource)
- @compile.class_scope(@middle).parent.should equal(@compile.class_scope(@top))
+ @compiler.class_scope(@middle).parent.should equal(@compiler.class_scope(@top))
end
it "should add the parent class's namespace to its namespace search path" do
@@ -126,6 +126,6 @@ describe Puppet::Parser::AST::HostClass, "when evaluating code" do
resource = @middle.evaluate(@scope)
@middle.evaluate_code(resource)
- @compile.class_scope(@middle).namespaces.should be_include(@top.namespace)
+ @compiler.class_scope(@middle).namespaces.should be_include(@top.namespace)
end
end
diff --git a/spec/unit/parser/collector.rb b/spec/unit/parser/collector.rb
index aedbe1b9a..e1ceb23ed 100755
--- a/spec/unit/parser/collector.rb
+++ b/spec/unit/parser/collector.rb
@@ -79,8 +79,8 @@ describe Puppet::Parser::Collector, "when collecting specific virtual resources"
@collector.resources = ["File[virtual1]"]
one = mock 'one'
one.stubs(:virtual=)
- @compile.expects(:delete_collection).with(@collector)
- @scope.expects(:compile).returns(@compile)
+ @compiler.expects(:delete_collection).with(@collector)
+ @scope.expects(:compiler).returns(@compiler)
@scope.stubs(:findresource).with("File[virtual1]").returns(one)
@collector.evaluate
end
@@ -89,7 +89,7 @@ describe Puppet::Parser::Collector, "when collecting specific virtual resources"
@collector.resources = ["File[virtual1]"]
one = mock 'one'
one.stubs(:virtual=)
- @compile.expects(:delete_collection).never
+ @compiler.expects(:delete_collection).never
@scope.stubs(:findresource).with("File[virtual1]").returns(nil)
@collector.evaluate
end
@@ -98,8 +98,8 @@ end
describe Puppet::Parser::Collector, "when collecting virtual resources" do
before do
@scope = mock 'scope'
- @compile = mock 'compile'
- @scope.stubs(:compile).returns(@compile)
+ @compiler = mock 'compile'
+ @scope.stubs(:compiler).returns(@compiler)
@resource_type = "Mytype"
@vquery = proc { |res| true }
@@ -113,7 +113,7 @@ describe Puppet::Parser::Collector, "when collecting virtual resources" do
one.stubs(:virtual=)
two.stubs(:virtual=)
- @compile.expects(:resources).returns([one, two])
+ @compiler.expects(:resources).returns([one, two])
@collector.evaluate.should == [one, two]
end
@@ -123,7 +123,7 @@ describe Puppet::Parser::Collector, "when collecting virtual resources" do
one.expects(:virtual=).with(false)
- @compile.expects(:resources).returns([one])
+ @compiler.expects(:resources).returns([one])
@collector.evaluate
end
@@ -135,7 +135,7 @@ describe Puppet::Parser::Collector, "when collecting virtual resources" do
one.stubs(:virtual=)
two.stubs(:virtual=)
- @compile.expects(:resources).returns([one, two])
+ @compiler.expects(:resources).returns([one, two])
@collector.evaluate.should == [one, two]
end
@@ -147,7 +147,7 @@ describe Puppet::Parser::Collector, "when collecting virtual resources" do
one.expects(:virtual=).with(false)
two.expects(:virtual=).with(false)
- @compile.expects(:resources).returns([one, two])
+ @compiler.expects(:resources).returns([one, two])
@collector = Puppet::Parser::Collector.new(@scope, @resource_type, nil, nil, :virtual)
@@ -161,7 +161,7 @@ describe Puppet::Parser::Collector, "when collecting virtual resources" do
one.expects(:virtual=).with(false)
two.expects(:virtual=).never
- @compile.expects(:resources).returns([one, two])
+ @compiler.expects(:resources).returns([one, two])
@collector.evaluate.should == [one]
end
@@ -173,7 +173,7 @@ describe Puppet::Parser::Collector, "when collecting virtual resources" do
one.expects(:virtual=).never
two.expects(:virtual=).never
- @compile.expects(:resources).returns([one, two])
+ @compiler.expects(:resources).returns([one, two])
@collector.evaluate.should be_false
end
@@ -187,7 +187,7 @@ describe Puppet::Parser::Collector, "when collecting virtual resources" do
one.expects(:virtual=).with(false)
two.expects(:virtual=).never
- @compile.expects(:resources).returns([one, two])
+ @compiler.expects(:resources).returns([one, two])
@collector.evaluate.should == [one]
end
@@ -198,8 +198,8 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
before do
@scope = stub 'scope', :host => "myhost", :debug => nil
- @compile = mock 'compile'
- @scope.stubs(:compile).returns(@compile)
+ @compiler = mock 'compile'
+ @scope.stubs(:compiler).returns(@compiler)
@resource_type = "Mytype"
@equery = "test = true"
@vquery = proc { |r| true }
@@ -218,7 +218,7 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
end
it "should use initialize the Rails support if ActiveRecord is not connected" do
- @compile.stubs(:resources).returns([])
+ @compiler.stubs(:resources).returns([])
ActiveRecord::Base.expects(:connected?).returns(false)
Puppet::Rails.expects(:init)
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
@@ -238,7 +238,7 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
two.stubs(:exported=)
two.stubs(:virtual=)
- @compile.expects(:resources).returns([one, two])
+ @compiler.expects(:resources).returns([one, two])
@collector.evaluate.should == [one, two]
end
@@ -251,7 +251,7 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
one.stubs(:exported=)
one.expects(:virtual=).with(false)
- @compile.expects(:resources).returns([one])
+ @compiler.expects(:resources).returns([one])
@collector.evaluate.should == [one]
end
@@ -268,10 +268,10 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
resource.stubs(:exported=)
resource.stubs(:virtual=)
- @compile.stubs(:resources).returns([])
+ @compiler.stubs(:resources).returns([])
@scope.stubs(:findresource).returns(nil)
- @compile.stubs(:add_resource)
+ @compiler.stubs(:add_resource)
@collector.evaluate.should == [resource]
end
@@ -288,10 +288,10 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
resource.stubs(:exported=)
resource.stubs(:virtual=)
- @compile.stubs(:resources).returns([])
+ @compiler.stubs(:resources).returns([])
@scope.stubs(:findresource).returns(nil)
- @compile.expects(:add_resource).with(@scope, resource)
+ @compiler.expects(:add_resource).with(@scope, resource)
@collector.evaluate.should == [resource]
end
@@ -309,10 +309,10 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
resource.expects(:exported=).with(false)
resource.stubs(:virtual=)
- @compile.stubs(:resources).returns([])
+ @compiler.stubs(:resources).returns([])
@scope.stubs(:findresource).returns(nil)
- @compile.stubs(:add_resource)
+ @compiler.stubs(:add_resource)
@collector.evaluate
end
@@ -328,10 +328,10 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
resource = mock 'resource'
- @compile.stubs(:resources).returns([])
+ @compiler.stubs(:resources).returns([])
@scope.stubs(:findresource).returns(inmemory)
- @compile.stubs(:add_resource)
+ @compiler.stubs(:add_resource)
proc { @collector.evaluate }.should raise_error(Puppet::ParseError)
end
@@ -347,10 +347,10 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
resource = mock 'resource'
- @compile.stubs(:resources).returns([])
+ @compiler.stubs(:resources).returns([])
@scope.stubs(:findresource).returns(inmemory)
- @compile.stubs(:add_resource)
+ @compiler.stubs(:add_resource)
proc { @collector.evaluate }.should_not raise_error(Puppet::ParseError)
end
@@ -361,14 +361,14 @@ describe Puppet::Parser::Collector, "when building its ActiveRecord query for co
before do
@scope = stub 'scope', :host => "myhost", :debug => nil
- @compile = mock 'compile'
- @scope.stubs(:compile).returns(@compile)
+ @compiler = mock 'compile'
+ @scope.stubs(:compiler).returns(@compiler)
@resource_type = "Mytype"
@equery = nil
@vquery = proc { |r| true }
@collector = Puppet::Parser::Collector.new(@scope, @resource_type, @equery, @vquery, :exported)
- @compile.stubs(:resources).returns([])
+ @compiler.stubs(:resources).returns([])
ActiveRecord::Base.stubs(:connected?).returns(false)
diff --git a/spec/unit/parser/compile.rb b/spec/unit/parser/compiler.rb
index 3903f6879..d3039996f 100755
--- a/spec/unit/parser/compile.rb
+++ b/spec/unit/parser/compiler.rb
@@ -2,91 +2,91 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-module CompileTesting
+module CompilerTesting
def setup
@node = Puppet::Node.new "testnode"
@parser = Puppet::Parser::Parser.new :environment => "development"
@scope_resource = stub 'scope_resource', :builtin? => true
@scope = stub 'scope', :resource => @scope_resource, :source => mock("source")
- @compile = Puppet::Parser::Compile.new(@node, @parser)
+ @compiler = Puppet::Parser::Compiler.new(@node, @parser)
end
end
-describe Puppet::Parser::Compile do
- include CompileTesting
+describe Puppet::Parser::Compiler do
+ include CompilerTesting
it "should be able to store references to class scopes" do
- lambda { @compile.class_set "myname", "myscope" }.should_not raise_error
+ lambda { @compiler.class_set "myname", "myscope" }.should_not raise_error
end
it "should be able to retrieve class scopes by name" do
- @compile.class_set "myname", "myscope"
- @compile.class_scope("myname").should == "myscope"
+ @compiler.class_set "myname", "myscope"
+ @compiler.class_scope("myname").should == "myscope"
end
it "should be able to retrieve class scopes by object" do
klass = mock 'ast_class'
klass.expects(:classname).returns("myname")
- @compile.class_set "myname", "myscope"
- @compile.class_scope(klass).should == "myscope"
+ @compiler.class_set "myname", "myscope"
+ @compiler.class_scope(klass).should == "myscope"
end
it "should be able to return a class list containing all set classes" do
- @compile.class_set "", "empty"
- @compile.class_set "one", "yep"
- @compile.class_set "two", "nope"
+ @compiler.class_set "", "empty"
+ @compiler.class_set "one", "yep"
+ @compiler.class_set "two", "nope"
- @compile.classlist.sort.should == %w{one two}.sort
+ @compiler.classlist.sort.should == %w{one two}.sort
end
end
-describe Puppet::Parser::Compile, " when initializing" do
- include CompileTesting
+describe Puppet::Parser::Compiler, " when initializing" do
+ include CompilerTesting
it "should set its node attribute" do
- @compile.node.should equal(@node)
+ @compiler.node.should equal(@node)
end
it "should set its parser attribute" do
- @compile.parser.should equal(@parser)
+ @compiler.parser.should equal(@parser)
end
it "should detect when ast nodes are absent" do
- @compile.ast_nodes?.should be_false
+ @compiler.ast_nodes?.should be_false
end
it "should detect when ast nodes are present" do
@parser.nodes["testing"] = "yay"
- @compile.ast_nodes?.should be_true
+ @compiler.ast_nodes?.should be_true
end
end
-describe Puppet::Parser::Compile, "when managing scopes" do
- include CompileTesting
+describe Puppet::Parser::Compiler, "when managing scopes" do
+ include CompilerTesting
it "should create a top scope" do
- @compile.topscope.should be_instance_of(Puppet::Parser::Scope)
+ @compiler.topscope.should be_instance_of(Puppet::Parser::Scope)
end
it "should be able to create new scopes" do
- @compile.newscope(@compile.topscope).should be_instance_of(Puppet::Parser::Scope)
+ @compiler.newscope(@compiler.topscope).should be_instance_of(Puppet::Parser::Scope)
end
it "should correctly set the level of newly created scopes" do
- @compile.newscope(@compile.topscope, :level => 5).level.should == 5
+ @compiler.newscope(@compiler.topscope, :level => 5).level.should == 5
end
it "should set the parent scope of the new scope to be the passed-in parent" do
scope = mock 'scope'
- newscope = @compile.newscope(scope)
+ newscope = @compiler.newscope(scope)
- @compile.parent(newscope).should equal(scope)
+ @compiler.parent(newscope).should equal(scope)
end
end
-describe Puppet::Parser::Compile, " when compiling" do
- include CompileTesting
+describe Puppet::Parser::Compiler, " when compiling" do
+ include CompilerTesting
def compile_methods
[:set_node_parameters, :evaluate_main, :evaluate_ast_node, :evaluate_node_classes, :evaluate_generators, :fail_on_unevaluated,
@@ -95,16 +95,16 @@ describe Puppet::Parser::Compile, " when compiling" do
# Stub all of the main compile methods except the ones we're specifically interested in.
def compile_stub(*except)
- (compile_methods - except).each { |m| @compile.stubs(m) }
+ (compile_methods - except).each { |m| @compiler.stubs(m) }
end
it "should set node parameters as variables in the top scope" do
params = {"a" => "b", "c" => "d"}
@node.stubs(:parameters).returns(params)
compile_stub(:set_node_parameters)
- @compile.compile
- @compile.topscope.lookupvar("a").should == "b"
- @compile.topscope.lookupvar("c").should == "d"
+ @compiler.compile
+ @compiler.topscope.lookupvar("a").should == "b"
+ @compiler.topscope.lookupvar("c").should == "d"
end
it "should evaluate any existing classes named in the node" do
@@ -115,34 +115,34 @@ describe Puppet::Parser::Compile, " when compiling" do
@node.stubs(:name).returns("whatever")
@node.stubs(:classes).returns(classes)
- @compile.expects(:evaluate_classes).with(classes, @compile.topscope)
- @compile.class.publicize_methods(:evaluate_node_classes) { @compile.evaluate_node_classes }
+ @compiler.expects(:evaluate_classes).with(classes, @compiler.topscope)
+ @compiler.class.publicize_methods(:evaluate_node_classes) { @compiler.evaluate_node_classes }
end
it "should enable ast_nodes if the parser has any nodes" do
@parser.expects(:nodes).returns(:one => :yay)
- @compile.ast_nodes?.should be_true
+ @compiler.ast_nodes?.should be_true
end
it "should disable ast_nodes if the parser has no nodes" do
@parser.expects(:nodes).returns({})
- @compile.ast_nodes?.should be_false
+ @compiler.ast_nodes?.should be_false
end
it "should evaluate the main class if it exists" do
compile_stub(:evaluate_main)
main_class = mock 'main_class'
main_class.expects(:evaluate_code).with { |r| r.is_a?(Puppet::Parser::Resource) }
- @compile.topscope.expects(:source=).with(main_class)
+ @compiler.topscope.expects(:source=).with(main_class)
@parser.stubs(:findclass).with("", "").returns(main_class)
- @compile.compile
+ @compiler.compile
end
it "should evaluate any node classes" do
@node.stubs(:classes).returns(%w{one two three four})
- @compile.expects(:evaluate_classes).with(%w{one two three four}, @compile.topscope)
- @compile.send(:evaluate_node_classes)
+ @compiler.expects(:evaluate_classes).with(%w{one two three four}, @compiler.topscope)
+ @compiler.send(:evaluate_node_classes)
end
it "should evaluate all added collections" do
@@ -152,52 +152,52 @@ describe Puppet::Parser::Compile, " when compiling" do
colls << mock("coll2-false")
colls.each { |c| c.expects(:evaluate).returns(false) }
- @compile.add_collection(colls[0])
- @compile.add_collection(colls[1])
+ @compiler.add_collection(colls[0])
+ @compiler.add_collection(colls[1])
compile_stub(:evaluate_generators)
- @compile.compile
+ @compiler.compile
end
it "should ignore builtin resources" do
resource = stub 'builtin', :ref => "File[testing]", :builtin? => true
- @compile.add_resource(@scope, resource)
+ @compiler.add_resource(@scope, resource)
resource.expects(:evaluate).never
- @compile.compile
+ @compiler.compile
end
it "should evaluate unevaluated resources" do
resource = stub 'notevaluated', :ref => "File[testing]", :builtin? => false, :evaluated? => false
- @compile.add_resource(@scope, resource)
+ @compiler.add_resource(@scope, resource)
# We have to now mark the resource as evaluated
resource.expects(:evaluate).with { |*whatever| resource.stubs(:evaluated?).returns true }
- @compile.compile
+ @compiler.compile
end
it "should not evaluate already-evaluated resources" do
resource = stub 'already_evaluated', :ref => "File[testing]", :builtin? => false, :evaluated? => true
- @compile.add_resource(@scope, resource)
+ @compiler.add_resource(@scope, resource)
resource.expects(:evaluate).never
- @compile.compile
+ @compiler.compile
end
it "should evaluate unevaluated resources created by evaluating other resources" do
resource = stub 'notevaluated', :ref => "File[testing]", :builtin? => false, :evaluated? => false
- @compile.add_resource(@scope, resource)
+ @compiler.add_resource(@scope, resource)
resource2 = stub 'created', :ref => "File[other]", :builtin? => false, :evaluated? => false
# We have to now mark the resource as evaluated
- resource.expects(:evaluate).with { |*whatever| resource.stubs(:evaluated?).returns(true); @compile.add_resource(@scope, resource2) }
+ resource.expects(:evaluate).with { |*whatever| resource.stubs(:evaluated?).returns(true); @compiler.add_resource(@scope, resource2) }
resource2.expects(:evaluate).with { |*whatever| resource2.stubs(:evaluated?).returns(true) }
- @compile.compile
+ @compiler.compile
end
it "should call finish() on all resources" do
@@ -205,21 +205,21 @@ describe Puppet::Parser::Compile, " when compiling" do
resource = Puppet::Parser::Resource.new :scope => @scope, :type => "file", :title => "finish"
resource.expects(:finish)
- @compile.add_resource(@scope, resource)
+ @compiler.add_resource(@scope, resource)
# And one that does not
dnf = stub "dnf", :ref => "File[dnf]"
- @compile.add_resource(@scope, dnf)
+ @compiler.add_resource(@scope, dnf)
- @compile.send(:finish)
+ @compiler.send(:finish)
end
it "should add resources that do not conflict with existing resources" do
resource = stub "noconflict", :ref => "File[yay]"
- @compile.add_resource(@scope, resource)
+ @compiler.add_resource(@scope, resource)
- @compile.catalog.should be_vertex(resource)
+ @compiler.catalog.should be_vertex(resource)
end
it "should fail to add resources that conflict with existing resources" do
@@ -229,86 +229,86 @@ describe Puppet::Parser::Compile, " when compiling" do
resource1 = stub "iso1conflict", :ref => "Mytype[yay]", :type => "mytype", :file => "eh", :line => 0
resource2 = stub "iso2conflict", :ref => "Mytype[yay]", :type => "mytype", :file => "eh", :line => 0
- @compile.add_resource(@scope, resource1)
- lambda { @compile.add_resource(@scope, resource2) }.should raise_error(ArgumentError)
+ @compiler.add_resource(@scope, resource1)
+ lambda { @compiler.add_resource(@scope, resource2) }.should raise_error(ArgumentError)
end
it "should have a method for looking up resources" do
resource = stub 'resource', :ref => "Yay[foo]"
- @compile.add_resource(@scope, resource)
- @compile.findresource("Yay[foo]").should equal(resource)
+ @compiler.add_resource(@scope, resource)
+ @compiler.findresource("Yay[foo]").should equal(resource)
end
it "should be able to look resources up by type and title" do
resource = stub 'resource', :ref => "Yay[foo]"
- @compile.add_resource(@scope, resource)
- @compile.findresource("Yay", "foo").should equal(resource)
+ @compiler.add_resource(@scope, resource)
+ @compiler.findresource("Yay", "foo").should equal(resource)
end
end
-describe Puppet::Parser::Compile, " when evaluating collections" do
- include CompileTesting
+describe Puppet::Parser::Compiler, " when evaluating collections" do
+ include CompilerTesting
it "should evaluate each collection" do
2.times { |i|
coll = mock 'coll%s' % i
- @compile.add_collection(coll)
+ @compiler.add_collection(coll)
# This is the hard part -- we have to emulate the fact that
# collections delete themselves if they are done evaluating.
coll.expects(:evaluate).with do
- @compile.delete_collection(coll)
+ @compiler.delete_collection(coll)
end
}
- @compile.class.publicize_methods(:evaluate_collections) { @compile.evaluate_collections }
+ @compiler.class.publicize_methods(:evaluate_collections) { @compiler.evaluate_collections }
end
it "should not fail when there are unevaluated resource collections that do not refer to specific resources" do
coll = stub 'coll', :evaluate => false
coll.expects(:resources).returns(nil)
- @compile.add_collection(coll)
+ @compiler.add_collection(coll)
- lambda { @compile.compile }.should_not raise_error
+ lambda { @compiler.compile }.should_not raise_error
end
it "should fail when there are unevaluated resource collections that refer to a specific resource" do
coll = stub 'coll', :evaluate => false
coll.expects(:resources).returns(:something)
- @compile.add_collection(coll)
+ @compiler.add_collection(coll)
- lambda { @compile.compile }.should raise_error(Puppet::ParseError)
+ lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
end
it "should fail when there are unevaluated resource collections that refer to multiple specific resources" do
coll = stub 'coll', :evaluate => false
coll.expects(:resources).returns([:one, :two])
- @compile.add_collection(coll)
+ @compiler.add_collection(coll)
- lambda { @compile.compile }.should raise_error(Puppet::ParseError)
+ lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
end
end
-describe Puppet::Parser::Compile, "when told to evaluate missing classes" do
- include CompileTesting
+describe Puppet::Parser::Compiler, "when told to evaluate missing classes" do
+ include CompilerTesting
it "should fail if there's no source listed for the scope" do
scope = stub 'scope', :source => nil
- proc { @compile.evaluate_classes(%w{one two}, scope) }.should raise_error(Puppet::DevError)
+ proc { @compiler.evaluate_classes(%w{one two}, scope) }.should raise_error(Puppet::DevError)
end
it "should tag the catalog with the name of each not-found class" do
- @compile.catalog.expects(:tag).with("notfound")
+ @compiler.catalog.expects(:tag).with("notfound")
@scope.expects(:findclass).with("notfound").returns(nil)
- @compile.evaluate_classes(%w{notfound}, @scope)
+ @compiler.evaluate_classes(%w{notfound}, @scope)
end
end
-describe Puppet::Parser::Compile, " when evaluating found classes" do
- include CompileTesting
+describe Puppet::Parser::Compiler, " when evaluating found classes" do
+ include CompilerTesting
before do
@class = stub 'class', :classname => "my::class"
@@ -318,76 +318,76 @@ describe Puppet::Parser::Compile, " when evaluating found classes" do
end
it "should evaluate each class" do
- @compile.catalog.stubs(:tag)
+ @compiler.catalog.stubs(:tag)
@class.expects(:evaluate).with(@scope)
- @compile.evaluate_classes(%w{myclass}, @scope)
+ @compiler.evaluate_classes(%w{myclass}, @scope)
end
it "should not evaluate the resources created for found classes unless asked" do
- @compile.catalog.stubs(:tag)
+ @compiler.catalog.stubs(:tag)
@resource.expects(:evaluate).never
@class.expects(:evaluate).returns(@resource)
- @compile.evaluate_classes(%w{myclass}, @scope)
+ @compiler.evaluate_classes(%w{myclass}, @scope)
end
it "should immediately evaluate the resources created for found classes when asked" do
- @compile.catalog.stubs(:tag)
+ @compiler.catalog.stubs(:tag)
@resource.expects(:evaluate)
@class.expects(:evaluate).returns(@resource)
- @compile.evaluate_classes(%w{myclass}, @scope, false)
+ @compiler.evaluate_classes(%w{myclass}, @scope, false)
end
it "should skip classes that have already been evaluated" do
- @compile.catalog.stubs(:tag)
+ @compiler.catalog.stubs(:tag)
- @compile.expects(:class_scope).with(@class).returns("something")
+ @compiler.expects(:class_scope).with(@class).returns("something")
- @compile.expects(:add_resource).never
+ @compiler.expects(:add_resource).never
@resource.expects(:evaluate).never
Puppet::Parser::Resource.expects(:new).never
- @compile.evaluate_classes(%w{myclass}, @scope, false)
+ @compiler.evaluate_classes(%w{myclass}, @scope, false)
end
it "should return the list of found classes" do
- @compile.catalog.stubs(:tag)
+ @compiler.catalog.stubs(:tag)
- @compile.stubs(:add_resource)
+ @compiler.stubs(:add_resource)
@scope.stubs(:findclass).with("notfound").returns(nil)
Puppet::Parser::Resource.stubs(:new).returns(@resource)
@class.stubs :evaluate
- @compile.evaluate_classes(%w{myclass notfound}, @scope).should == %w{myclass}
+ @compiler.evaluate_classes(%w{myclass notfound}, @scope).should == %w{myclass}
end
end
-describe Puppet::Parser::Compile, " when evaluating AST nodes with no AST nodes present" do
- include CompileTesting
+describe Puppet::Parser::Compiler, " when evaluating AST nodes with no AST nodes present" do
+ include CompilerTesting
it "should do nothing" do
- @compile.expects(:ast_nodes?).returns(false)
- @compile.parser.expects(:nodes).never
+ @compiler.expects(:ast_nodes?).returns(false)
+ @compiler.parser.expects(:nodes).never
Puppet::Parser::Resource.expects(:new).never
- @compile.send(:evaluate_ast_node)
+ @compiler.send(:evaluate_ast_node)
end
end
-describe Puppet::Parser::Compile, " when evaluating AST nodes with AST nodes present" do
- include CompileTesting
+describe Puppet::Parser::Compiler, " when evaluating AST nodes with AST nodes present" do
+ include CompilerTesting
before do
@nodes = mock 'node_hash'
- @compile.stubs(:ast_nodes?).returns(true)
- @compile.parser.stubs(:nodes).returns(@nodes)
+ @compiler.stubs(:ast_nodes?).returns(true)
+ @compiler.parser.stubs(:nodes).returns(@nodes)
# Set some names for our test
@node.stubs(:names).returns(%w{a b c})
@@ -400,7 +400,7 @@ describe Puppet::Parser::Compile, " when evaluating AST nodes with AST nodes pre
end
it "should fail if the named node cannot be found" do
- proc { @compile.send(:evaluate_ast_node) }.should raise_error(Puppet::ParseError)
+ proc { @compiler.send(:evaluate_ast_node) }.should raise_error(Puppet::ParseError)
end
it "should evaluate the first node class matching the node name" do
@@ -410,7 +410,7 @@ describe Puppet::Parser::Compile, " when evaluating AST nodes with AST nodes pre
node_resource = stub 'node resource', :ref => "Node[c]", :evaluate => nil
node_class.expects(:evaluate).returns(node_resource)
- @compile.compile
+ @compiler.compile
end
it "should match the default node if no matching node can be found" do
@@ -420,7 +420,7 @@ describe Puppet::Parser::Compile, " when evaluating AST nodes with AST nodes pre
node_resource = stub 'node resource', :ref => "Node[default]", :evaluate => nil
node_class.expects(:evaluate).returns(node_resource)
- @compile.compile
+ @compiler.compile
end
it "should evaluate the node resource immediately rather than using lazy evaluation" do
@@ -432,7 +432,7 @@ describe Puppet::Parser::Compile, " when evaluating AST nodes with AST nodes pre
node_resource.expects(:evaluate)
- @compile.send(:evaluate_ast_node)
+ @compiler.send(:evaluate_ast_node)
end
it "should set the node's scope as the top scope" do
@@ -443,38 +443,38 @@ describe Puppet::Parser::Compile, " when evaluating AST nodes with AST nodes pre
# The #evaluate method normally does this.
scope = stub 'scope', :source => "mysource"
- @compile.class_set(node_class.classname, scope)
+ @compiler.class_set(node_class.classname, scope)
node_resource.stubs(:evaluate)
- @compile.compile
+ @compiler.compile
- @compile.topscope.should equal(scope)
+ @compiler.topscope.should equal(scope)
end
end
-describe Puppet::Parser::Compile, "when storing compiled resources" do
- include CompileTesting
+describe Puppet::Parser::Compiler, "when storing compiled resources" do
+ include CompilerTesting
it "should store the resources" do
Puppet.features.expects(:rails?).returns(true)
Puppet::Rails.expects(:connect)
- @compile.catalog.expects(:vertices).returns(:resources)
+ @compiler.catalog.expects(:vertices).returns(:resources)
- @compile.expects(:store_to_active_record).with(@node, :resources)
- @compile.send(:store)
+ @compiler.expects(:store_to_active_record).with(@node, :resources)
+ @compiler.send(:store)
end
it "should store to active_record" do
@node.expects(:name).returns("myname")
Puppet::Rails::Host.stubs(:transaction).yields
Puppet::Rails::Host.expects(:store).with(@node, :resources)
- @compile.send(:store_to_active_record, @node, :resources)
+ @compiler.send(:store_to_active_record, @node, :resources)
end
end
-describe Puppet::Parser::Compile, "when managing resource overrides" do
- include CompileTesting
+describe Puppet::Parser::Compiler, "when managing resource overrides" do
+ include CompilerTesting
before do
@override = stub 'override', :ref => "My[ref]"
@@ -482,41 +482,41 @@ describe Puppet::Parser::Compile, "when managing resource overrides" do
end
it "should be able to store overrides" do
- lambda { @compile.add_override(@override) }.should_not raise_error
+ lambda { @compiler.add_override(@override) }.should_not raise_error
end
it "should apply overrides to the appropriate resources" do
- @compile.add_resource(@scope, @resource)
+ @compiler.add_resource(@scope, @resource)
@resource.expects(:merge).with(@override)
- @compile.add_override(@override)
+ @compiler.add_override(@override)
- @compile.compile
+ @compiler.compile
end
it "should accept overrides before the related resource has been created" do
@resource.expects(:merge).with(@override)
# First store the override
- @compile.add_override(@override)
+ @compiler.add_override(@override)
# Then the resource
- @compile.add_resource(@scope, @resource)
+ @compiler.add_resource(@scope, @resource)
# And compile, so they get resolved
- @compile.compile
+ @compiler.compile
end
it "should fail if the compile is finished and resource overrides have not been applied" do
- @compile.add_override(@override)
+ @compiler.add_override(@override)
- lambda { @compile.compile }.should raise_error(Puppet::ParseError)
+ lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
end
end
# #620 - Nodes and classes should conflict, else classes don't get evaluated
-describe Puppet::Parser::Compile, "when evaluating nodes and classes with the same name (#620)" do
- include CompileTesting
+describe Puppet::Parser::Compiler, "when evaluating nodes and classes with the same name (#620)" do
+ include CompilerTesting
before do
@node = stub :nodescope? => true
@@ -524,12 +524,12 @@ describe Puppet::Parser::Compile, "when evaluating nodes and classes with the sa
end
it "should fail if a node already exists with the same name as the class being evaluated" do
- @compile.class_set("one", @node)
- lambda { @compile.class_set("one", @class) }.should raise_error(Puppet::ParseError)
+ @compiler.class_set("one", @node)
+ lambda { @compiler.class_set("one", @class) }.should raise_error(Puppet::ParseError)
end
it "should fail if a class already exists with the same name as the node being evaluated" do
- @compile.class_set("one", @class)
- lambda { @compile.class_set("one", @node) }.should raise_error(Puppet::ParseError)
+ @compiler.class_set("one", @class)
+ lambda { @compiler.class_set("one", @node) }.should raise_error(Puppet::ParseError)
end
end
diff --git a/spec/unit/parser/interpreter.rb b/spec/unit/parser/interpreter.rb
index ed30ced93..7885f0542 100755
--- a/spec/unit/parser/interpreter.rb
+++ b/spec/unit/parser/interpreter.rb
@@ -115,14 +115,14 @@ describe Puppet::Parser::Interpreter, " when compiling catalog" do
before do
@interp = Puppet::Parser::Interpreter.new
@node = stub 'node', :environment => :myenv
- @compile = mock 'compile'
+ @compiler = mock 'compile'
@parser = mock 'parser'
end
it "should create a compile with the node and parser" do
- @compile.expects(:compile).returns(:config)
+ @compiler.expects(:compile).returns(:config)
@interp.expects(:parser).with(:myenv).returns(@parser)
- Puppet::Parser::Compile.expects(:new).with(@node, @parser).returns(@compile)
+ Puppet::Parser::Compiler.expects(:new).with(@node, @parser).returns(@compiler)
@interp.compile(@node)
end
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 099cfd05e..a5a49e2a6 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -15,8 +15,8 @@ describe Puppet::Parser::Resource, " when evaluating" do
@class = @parser.newclass "myclass"
@nodedef = @parser.newnode("mynode")[0]
@node = Puppet::Node.new("yaynode")
- @compile = Puppet::Parser::Compile.new(@node, @parser)
- @scope = @compile.topscope
+ @compiler = Puppet::Parser::Compiler.new(@node, @parser)
+ @scope = @compiler.topscope
end
it "should evaluate the associated AST definition" do
@@ -47,8 +47,8 @@ describe Puppet::Parser::Resource, " when finishing" do
@class = @parser.newclass "myclass"
@nodedef = @parser.newnode("mynode")[0]
@node = Puppet::Node.new("yaynode")
- @compile = Puppet::Parser::Compile.new(@node, @parser)
- @scope = @compile.topscope
+ @compiler = Puppet::Parser::Compiler.new(@node, @parser)
+ @scope = @compiler.topscope
@resource = Puppet::Parser::Resource.new(:type => "mydefine", :title => "whatever", :scope => @scope, :source => @source)
end
diff --git a/spec/unit/parser/resource/reference.rb b/spec/unit/parser/resource/reference.rb
index e7385f796..147f772d1 100755
--- a/spec/unit/parser/resource/reference.rb
+++ b/spec/unit/parser/resource/reference.rb
@@ -52,23 +52,23 @@ describe Puppet::Parser::Resource::Reference, " when modeling defined types" do
@nodedef = @parser.newnode("mynode")[0]
@node = Puppet::Node.new("yaynode")
- @compile = Puppet::Parser::Compile.new(@node, @parser)
+ @compiler = Puppet::Parser::Compiler.new(@node, @parser)
end
it "should be able to find defined types" do
- ref = @type.new(:type => "mydefine", :title => "/tmp/yay", :scope => @compile.topscope)
+ ref = @type.new(:type => "mydefine", :title => "/tmp/yay", :scope => @compiler.topscope)
ref.builtin?.should be_false
ref.definedtype.should equal(@definition)
end
it "should be able to find classes" do
- ref = @type.new(:type => "class", :title => "myclass", :scope => @compile.topscope)
+ ref = @type.new(:type => "class", :title => "myclass", :scope => @compiler.topscope)
ref.builtin?.should be_false
ref.definedtype.should equal(@class)
end
it "should be able to find nodes" do
- ref = @type.new(:type => "node", :title => "mynode", :scope => @compile.topscope)
+ ref = @type.new(:type => "node", :title => "mynode", :scope => @compiler.topscope)
ref.builtin?.should be_false
ref.definedtype.object_id.should == @nodedef.object_id
end
diff --git a/test/language/ast.rb b/test/language/ast.rb
index 9b8c74cfb..8c0f31aba 100755
--- a/test/language/ast.rb
+++ b/test/language/ast.rb
@@ -57,7 +57,7 @@ class TestAST < Test::Unit::TestCase
end
Puppet::Parser::Resource.expects(:new).with { |o| o.is_a?(Hash) }.returns(:override)
- scope.compile.expects(:add_override).with(:override)
+ scope.compiler.expects(:add_override).with(:override)
ret = nil
assert_nothing_raised do
ret = ref.evaluate scope
@@ -111,7 +111,7 @@ class TestAST < Test::Unit::TestCase
assert_instance_of(Puppet::Parser::Collector, ret)
# Now make sure we get it back from the scope
- colls = scope.compile.instance_variable_get("@collections")
+ colls = scope.compiler.instance_variable_get("@collections")
assert_equal([ret], colls, "Did not store collector in config's collection list")
end
diff --git a/test/language/ast/definition.rb b/test/language/ast/definition.rb
index d4e4bd185..1585c5b1d 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 = mkcompile
+ config = mkcompiler
config.send(:evaluate_main)
scope = config.topscope
klass = parser.newdefine "yayness",
diff --git a/test/language/ast/node.rb b/test/language/ast/node.rb
index df732480d..a90f05adf 100755
--- a/test/language/ast/node.rb
+++ b/test/language/ast/node.rb
@@ -18,7 +18,7 @@ class TestASTNode < Test::Unit::TestCase
def test_node
scope = mkscope
- parser = scope.compile.parser
+ parser = scope.compiler.parser
# Define a base node
basenode = parser.newnode "basenode", :code => AST::ASTArray.new(:children => [
diff --git a/test/language/ast/resource.rb b/test/language/ast/resource.rb
index aff1dba16..97541d92f 100755
--- a/test/language/ast/resource.rb
+++ b/test/language/ast/resource.rb
@@ -16,7 +16,7 @@ class TestASTResource< Test::Unit::TestCase
def setup
super
@scope = mkscope
- @parser = @scope.compile.parser
+ @parser = @scope.compiler.parser
end
def newdef(type, title, params = nil)
diff --git a/test/language/ast/resource_reference.rb b/test/language/ast/resource_reference.rb
index 9de3391d9..1f554d90f 100755
--- a/test/language/ast/resource_reference.rb
+++ b/test/language/ast/resource_reference.rb
@@ -20,7 +20,7 @@ class TestASTResourceReference < Test::Unit::TestCase
def setup
super
@scope = mkscope
- @parser = @scope.compile.parser
+ @parser = @scope.compiler.parser
end
def test_evaluate
diff --git a/test/language/functions.rb b/test/language/functions.rb
index b8f7d4313..a5d52d7ac 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -66,7 +66,7 @@ class TestLangFunctions < Test::Unit::TestCase
# Now make sure we correctly get tags.
scope.resource.tag("resourcetag")
assert(scope.function_tagged("resourcetag"), "tagged function did not catch resource tags")
- scope.compile.catalog.tag("configtag")
+ scope.compiler.catalog.tag("configtag")
assert(scope.function_tagged("configtag"), "tagged function did not catch catalog tags")
end
@@ -308,7 +308,7 @@ class TestLangFunctions < Test::Unit::TestCase
def test_realize
scope = mkscope
- parser = scope.compile.parser
+ parser = scope.compiler.parser
# Make a definition
parser.newdefine("mytype")
@@ -318,7 +318,7 @@ class TestLangFunctions < Test::Unit::TestCase
virtual = mkresource(:type => type, :title => title,
:virtual => true, :params => {}, :scope => scope)
- scope.compile.add_resource(scope, virtual)
+ scope.compiler.add_resource(scope, virtual)
ref = Puppet::Parser::Resource::Reference.new(
:type => type, :title => title,
@@ -330,13 +330,13 @@ class TestLangFunctions < Test::Unit::TestCase
end
# Make sure it created a collection
- assert_equal(1, scope.compile.collections.length,
+ assert_equal(1, scope.compiler.collections.length,
"Did not set collection")
assert_nothing_raised do
- scope.compile.collections.each do |coll| coll.evaluate end
+ scope.compiler.collections.each do |coll| coll.evaluate end
end
- scope.compile.collections.clear
+ scope.compiler.collections.clear
# Now make sure the virtual resource is no longer virtual
assert(! virtual.virtual?, "Did not make virtual resource real")
@@ -354,17 +354,17 @@ class TestLangFunctions < Test::Unit::TestCase
end
# Make sure it created a collection
- assert_equal(1, scope.compile.collections.length,
+ assert_equal(1, scope.compiler.collections.length,
"Did not set collection")
# And the collection has our resource in it
- assert_equal([none.to_s], scope.compile.collections[0].resources,
+ assert_equal([none.to_s], scope.compiler.collections[0].resources,
"Did not set resources in collection")
end
def test_defined
scope = mkscope
- parser = scope.compile.parser
+ parser = scope.compiler.parser
parser.newclass("yayness")
parser.newdefine("rahness")
@@ -385,7 +385,7 @@ class TestLangFunctions < Test::Unit::TestCase
"Multiple falses were somehow true")
# Now make sure we can test resources
- scope.compile.add_resource(scope, mkresource(:type => "file", :title => "/tmp/rahness",
+ scope.compiler.add_resource(scope, mkresource(:type => "file", :title => "/tmp/rahness",
:scope => scope, :source => scope.source,
:params => {:owner => "root"}))
@@ -420,7 +420,7 @@ class TestLangFunctions < Test::Unit::TestCase
def test_include
scope = mkscope
- parser = scope.compile.parser
+ parser = scope.compiler.parser
assert_raise(Puppet::ParseError, "did not throw error on missing class") do
scope.function_include("nosuchclass")
@@ -428,7 +428,7 @@ class TestLangFunctions < Test::Unit::TestCase
parser.newclass("myclass")
- scope.compile.expects(:evaluate_classes).with(%w{myclass otherclass}, scope, false).returns(%w{myclass otherclass})
+ scope.compiler.expects(:evaluate_classes).with(%w{myclass otherclass}, scope, false).returns(%w{myclass otherclass})
assert_nothing_raised do
scope.function_include(["myclass", "otherclass"])
@@ -480,7 +480,7 @@ class TestLangFunctions < Test::Unit::TestCase
assert_equal("yay-foo\n", %x{#{command} foo}, "command did not work")
scope = mkscope
- parser = scope.compile.parser
+ parser = scope.compiler.parser
val = nil
assert_nothing_raised("Could not call generator with no args") do
diff --git a/test/language/parser.rb b/test/language/parser.rb
index 3df4d0bb8..2a0e9c02d 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -45,7 +45,7 @@ class TestParser < Test::Unit::TestCase
assert_raise(Puppet::ParseError, "Did not fail while parsing %s" % file) {
parser.file = file
ast = parser.parse
- config = mkcompile(parser)
+ config = mkcompiler(parser)
config.compile
#ast.classes[""].evaluate config.topscope
}
@@ -868,7 +868,7 @@ file { "/tmp/yayness":
def test_newclass
scope = mkscope
- parser = scope.compile.parser
+ parser = scope.compiler.parser
mkcode = proc do |ary|
classes = ary.collect do |string|
diff --git a/test/language/resource.rb b/test/language/resource.rb
index dbb1ab9f9..608e7c995 100755
--- a/test/language/resource.rb
+++ b/test/language/resource.rb
@@ -341,7 +341,7 @@ class TestResource < PuppetTest::TestCase
{:name => "one", :title => "two"},
{:title => "three"},
].each do |hash|
- config = mkcompile parser
+ config = mkcompiler parser
args = {:type => "yayness", :title => hash[:title],
:source => klass, :scope => config.topscope}
if hash[:name]
@@ -388,7 +388,7 @@ class TestResource < PuppetTest::TestCase
:code => resourcedef("file", varref("name"),
"mode" => "644"))
- config = mkcompile(parser)
+ config = mkcompiler(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 b35687e66..9c0e583e4 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 = mkcompile
+ config = mkcompiler
topscope = config.topscope
midscope = config.newscope(topscope)
botscope = config.newscope(midscope)
@@ -94,7 +94,7 @@ class TestScope < Test::Unit::TestCase
classes = ["", "one", "one::two", "one::two::three"].each do |name|
klass = parser.newclass(name)
Puppet::Parser::Resource.new(:type => "class", :title => name, :scope => scope, :source => mock('source')).evaluate
- scopes[name] = scope.compile.class_scope(klass)
+ scopes[name] = scope.compiler.class_scope(klass)
end
classes.each do |name|
@@ -125,7 +125,7 @@ class TestScope < Test::Unit::TestCase
end
def test_setdefaults
- config = mkcompile
+ config = mkcompiler
scope = config.topscope
@@ -151,7 +151,7 @@ class TestScope < Test::Unit::TestCase
end
def test_lookupdefaults
- config = mkcompile
+ config = mkcompiler
top = config.topscope
# Make a subscope
@@ -179,7 +179,7 @@ class TestScope < Test::Unit::TestCase
end
def test_parent
- config = mkcompile
+ config = mkcompiler
top = config.topscope
# Make a subscope
@@ -205,7 +205,7 @@ class TestScope < Test::Unit::TestCase
%w{one one::two one::two::three}.each do |name|
klass = parser.newclass(name)
Puppet::Parser::Resource.new(:type => "class", :title => name, :scope => scope, :source => mock('source')).evaluate
- scopes[name] = scope.compile.class_scope(klass)
+ scopes[name] = scope.compiler.class_scope(klass)
scopes[name].setvar("test", "value-%s" % name.sub(/.+::/,''))
end
@@ -287,10 +287,10 @@ class TestScope < Test::Unit::TestCase
function.evaluate scope
end
- scope.compile.send(:evaluate_generators)
+ scope.compiler.send(:evaluate_generators)
[myclass, otherclass].each do |klass|
- assert(scope.compile.class_scope(klass),
+ assert(scope.compiler.class_scope(klass),
"%s was not set" % klass.classname)
end
end
@@ -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 = mkcompile
+ config = mkcompiler
parser = config.parser
# Create a default source
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb
index 36bb68a77..1a08ecbae 100644
--- a/test/lib/puppettest/parsertesting.rb
+++ b/test/lib/puppettest/parsertesting.rb
@@ -5,7 +5,7 @@ module PuppetTest::ParserTesting
include PuppetTest
AST = Puppet::Parser::AST
- Compile = Puppet::Parser::Compile
+ Compiler = Puppet::Parser::Compiler
# A fake class that we can use for testing evaluation.
class FakeAST
@@ -41,10 +41,10 @@ module PuppetTest::ParserTesting
)
end
- def mkcompile(parser = nil)
+ def mkcompiler(parser = nil)
parser ||= mkparser
node = mknode
- return Compile.new(node, parser)
+ return Compiler.new(node, parser)
end
def mknode(name = nil)
@@ -64,15 +64,15 @@ module PuppetTest::ParserTesting
def mkscope(hash = {})
hash[:parser] ||= mkparser
- compile ||= mkcompile(hash[:parser])
- compile.topscope.source = (hash[:parser].findclass("", "") || hash[:parser].newclass(""))
+ compiler ||= mkcompiler(hash[:parser])
+ compiler.topscope.source = (hash[:parser].findclass("", "") || hash[:parser].newclass(""))
- unless compile.topscope.source
+ unless compiler.topscope.source
raise "Could not find source for scope"
end
# Make the 'main' stuff
- compile.send(:evaluate_main)
- compile.topscope
+ compiler.send(:evaluate_main)
+ compiler.topscope
end
def classobj(name, hash = {})