[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
test branch
puppet-dev at googlegroups.com
Wed Jul 14 10:31:40 UTC 2010
The following commit has been merged in the upstream branch:
commit 67ef78d9f231661d0fdd6260d470cf0d06f1bac2
Author: Luke Kanies <luke at reductivelabs.com>
Date: Thu Jan 7 13:08:50 2010 -0800
Removing Interpreter class
It's no longer necessary, given the new ResourceTypeCollection
class.
Signed-off-by: Luke Kanies <luke at reductivelabs.com>
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 3c5eebb..f53e664 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -151,11 +151,11 @@ module Puppet
end
require 'puppet/type'
+require 'puppet/parser'
require 'puppet/network'
require 'puppet/ssl'
require 'puppet/module'
require 'puppet/util/storage'
-require 'puppet/parser/interpreter'
if Puppet[:storeconfigs]
require 'puppet/rails'
diff --git a/lib/puppet/application/main.rb b/lib/puppet/application/main.rb
index 5eab81a..3813df6 100644
--- a/lib/puppet/application/main.rb
+++ b/lib/puppet/application/main.rb
@@ -72,7 +72,7 @@ Puppet::Application.new(:main) do
Puppet[:manifest] = ARGV.shift
end
begin
- Puppet::Parser::Interpreter.new.parser(Puppet[:environment])
+ Puppet::Parser::ResourceTypeCollection.new(Puppet[:environment]).perform_initial_import
rescue => detail
Puppet.err detail
exit 1
diff --git a/lib/puppet/application/server.rb b/lib/puppet/application/server.rb
index 57d29e0..e9253c6 100644
--- a/lib/puppet/application/server.rb
+++ b/lib/puppet/application/server.rb
@@ -69,7 +69,7 @@ Puppet::Application.new(:server) do
command(:parseonly) do
begin
- Puppet::Parser::Interpreter.new.parser(Puppet[:environment])
+ Puppet::Parser::ResourceTypeCollection.new(Puppet[:environment]).perform_initial_import
rescue => detail
Puppet.err detail
exit 1
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb
index ecb1c74..f83245a 100644
--- a/lib/puppet/indirector/catalog/compiler.rb
+++ b/lib/puppet/indirector/catalog/compiler.rb
@@ -1,7 +1,6 @@
require 'puppet/node'
require 'puppet/resource/catalog'
require 'puppet/indirector/code'
-require 'puppet/parser/interpreter'
require 'yaml'
class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
@@ -52,14 +51,6 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
setup_database_backend if Puppet[:storeconfigs]
end
- # Create/return our interpreter.
- def interpreter
- unless defined?(@interpreter) and @interpreter
- @interpreter = create_interpreter
- end
- @interpreter
- end
-
# Is our compiler part of a network, or are we just local?
def networked?
$0 =~ /puppetmasterd/
@@ -75,7 +66,6 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
# Compile the actual catalog.
def compile(node)
- # Ask the interpreter to compile the catalog.
str = "Compiled catalog for %s" % node.name
if node.environment
str += " in environment %s" % node.environment
@@ -86,7 +76,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
benchmark(loglevel, "Compiled catalog for %s" % node.name) do
begin
- config = interpreter.compile(node)
+ return Puppet::Parser::Compiler.compile(node)
rescue Puppet::Error => detail
Puppet.err(detail.to_s) if networked?
raise
@@ -96,11 +86,6 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
return config
end
- # Create our interpreter object.
- def create_interpreter
- return Puppet::Parser::Interpreter.new
- end
-
# Turn our host name into a node object.
def find_node(name)
begin
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index e21e1e6..d123fd6 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -1,6 +1,5 @@
require 'openssl'
require 'puppet'
-require 'puppet/parser/interpreter'
require 'puppet/sslcertificates'
require 'xmlrpc/server'
require 'yaml'
@@ -44,8 +43,6 @@ class Puppet::Network::Handler
@ca = nil
end
- Puppet.debug("Creating interpreter")
-
# This is only used by the cfengine module, or if --loadclasses was
# specified in +puppet+.
if hash.include?(:Classes)
diff --git a/lib/puppet/parser.rb b/lib/puppet/parser.rb
new file mode 100644
index 0000000..3eda738
--- /dev/null
+++ b/lib/puppet/parser.rb
@@ -0,0 +1,4 @@
+require 'puppet/parser/parser'
+require 'puppet/parser/compiler'
+require 'puppet/parser/resource_type_collection'
+
diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb
index f9c8f70..25b0641 100644
--- a/lib/puppet/parser/compiler.rb
+++ b/lib/puppet/parser/compiler.rb
@@ -14,6 +14,13 @@ class Puppet::Parser::Compiler
include Puppet::Util::Errors
include Puppet::Parser::ResourceTypeCollectionHelper
+ def self.compile(node)
+ new(node).compile.to_resource
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ raise Puppet::Error, "#{detail} on node #{node.name}"
+ end
+
attr_reader :node, :facts, :collections, :catalog, :node_scope, :resources
# Add a collection to the global list.
diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra
index 76a82e3..0e09018 100644
--- a/lib/puppet/parser/grammar.ra
+++ b/lib/puppet/parser/grammar.ra
@@ -838,7 +838,6 @@ require 'puppet'
require 'puppet/util/loadedfile'
require 'puppet/parser/lexer'
require 'puppet/parser/ast'
-#require 'puppet/parser/interpreter'
module Puppet
class ParseError < Puppet::Error; end
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
deleted file mode 100644
index eea9afc..0000000
--- a/lib/puppet/parser/interpreter.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require 'puppet'
-require 'timeout'
-require 'puppet/rails'
-require 'puppet/util/methodhelper'
-require 'puppet/parser/parser'
-require 'puppet/parser/compiler'
-require 'puppet/parser/scope'
-
-# The interpreter is a very simple entry-point class that
-# manages the existence of the parser (e.g., replacing it
-# when files are reparsed). You can feed it a node and
-# get the node's catalog back.
-class Puppet::Parser::Interpreter
- include Puppet::Util
-
- attr_accessor :usenodes
-
- include Puppet::Util::Errors
-
- # evaluate our whole tree
- def compile(node)
- begin
- return Puppet::Parser::Compiler.new(node).compile.to_resource
- rescue => detail
- puts detail.backtrace if Puppet[:trace]
- raise Puppet::Error, detail.to_s + " on node %s" % node.name
- end
- end
-
- # create our interpreter
- def initialize
- @parsers = {}
- end
-
- # Return the parser for a specific environment.
- def parser(environment)
- if ! @parsers[environment] or @parsers[environment].reparse?
- # This will throw an exception if it does not succeed.
- @parsers[environment] = create_parser(environment)
- end
- @parsers[environment]
- end
-
- private
-
- # Create a new parser object and pre-parse the configuration.
- def create_parser(environment)
- begin
- parser = Puppet::Parser::Parser.new(environment)
- if code = Puppet.settings.uninterpolated_value(:code, environment) and code != ""
- parser.string = code
- else
- file = Puppet.settings.value(:manifest, environment)
- parser.file = file
- end
- parser.parse
- return parser
- rescue => detail
- msg = "Could not parse"
- if environment and environment != ""
- msg += " for environment %s" % environment
- end
- msg += ": %s" % detail.to_s
- error = Puppet::Error.new(msg)
- error.set_backtrace(detail.backtrace)
- raise error
- end
- end
-end
diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb
index 7e9235f..a3dc5be 100644
--- a/lib/puppet/parser/parser.rb
+++ b/lib/puppet/parser/parser.rb
@@ -11,7 +11,6 @@ require 'puppet'
require 'puppet/util/loadedfile'
require 'puppet/parser/lexer'
require 'puppet/parser/ast'
-#require 'puppet/parser/interpreter'
module Puppet
class ParseError < Puppet::Error; end
@@ -29,7 +28,7 @@ module Puppet
class Parser < Racc::Parser
-module_eval <<'..end grammar.ra modeval..id884310a196', 'grammar.ra', 853
+module_eval <<'..end grammar.ra modeval..id8da59540c6', 'grammar.ra', 852
# It got too annoying having code in a file that needs to be compiled.
require 'puppet/parser/parser_support'
@@ -41,7 +40,7 @@ require 'puppet/parser/parser_support'
# $Id$
-..end grammar.ra modeval..id884310a196
+..end grammar.ra modeval..id8da59540c6
##### racc 1.4.5 generates ###
diff --git a/spec/integration/parser/functions/include.rb b/spec/integration/parser/functions/include.rb
new file mode 100755
index 0000000..64346bf
--- /dev/null
+++ b/spec/integration/parser/functions/include.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe "The include function" do
+ before :each do
+ @node = Puppet::Node.new("mynode")
+ @compiler = Puppet::Parser::Compiler.new(@node)
+ @compiler.send(:evaluate_main)
+ @scope = @compiler.topscope
+ # preload our functions
+ Puppet::Parser::Functions.function(:include)
+ Puppet::Parser::Functions.function(:require)
+ end
+
+ it "should add a containment relationship between the 'included' class and our class" do
+ @compiler.known_resource_types.add Puppet::Parser::ResourceType.new(:hostclass, "includedclass")
+
+ @scope.function_include("includedclass")
+
+ klass_resource = @compiler.findresource(:class,"includedclass")
+ klass_resource.should be_instance_of(Puppet::Parser::Resource)
+ @compiler.catalog.should be_edge(@scope.resource, klass_resource)
+ end
+end
diff --git a/spec/integration/parser/functions/require.rb b/spec/integration/parser/functions/require.rb
index 6f169ad..5f95ec5 100755
--- a/spec/integration/parser/functions/require.rb
+++ b/spec/integration/parser/functions/require.rb
@@ -2,12 +2,10 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
-describe "the require function" do
-
+describe "The require function" do
before :each do
- @parser = Puppet::Parser::Parser.new :Code => ""
@node = Puppet::Node.new("mynode")
- @compiler = Puppet::Parser::Compiler.new(@node, @parser)
+ @compiler = Puppet::Parser::Compiler.new(@node)
@compiler.send(:evaluate_main)
@compiler.catalog.client_version = "0.25"
@@ -17,8 +15,8 @@ describe "the require function" do
Puppet::Parser::Functions.function(:require)
end
- it "should add a relationship between the 'required' class and our class" do
- @parser.newclass("requiredclass")
+ it "should add a dependency between the 'required' class and our class" do
+ @compiler.known_resource_types.add Puppet::Parser::ResourceType.new(:hostclass, "requiredclass")
@scope.function_require("requiredclass")
@scope.resource["require"].should_not be_nil
@@ -44,43 +42,3 @@ describe "the require function" do
end
end
-
-describe "the include function" do
- require 'puppet_spec/files'
- include PuppetSpec::Files
-
- before :each do
- @real_dir = Dir.getwd
- @temp_dir = tmpfile('include_function_integration_test')
- Dir.mkdir @temp_dir
- Dir.chdir @temp_dir
- @parser = Puppet::Parser::Parser.new :Code => ""
- @node = Puppet::Node.new("mynode")
- @compiler = Puppet::Parser::Compiler.new(@node, @parser)
- @compiler.send(:evaluate_main)
- @scope = @compiler.topscope
- # preload our functions
- Puppet::Parser::Functions.function(:include)
- Puppet::Parser::Functions.function(:require)
- end
-
- after :each do
- Dir.chdir @real_dir
- Dir.rmdir @temp_dir
- end
-
- def with_file(filename,contents)
- path = File.join(@temp_dir,filename)
- File.open(path, "w") { |f|f.puts contents }
- yield
- File.delete(path)
- end
-
- it "should add a relationship between the 'included' class and our class" do
- with_file('includedclass',"class includedclass {}") {
- @scope.function_include("includedclass")
- }
- @compiler.catalog.edge?(@scope.resource, at compiler.findresource(:class,"includedclass")).should be_true
- end
-
-end
diff --git a/spec/unit/application/main.rb b/spec/unit/application/main.rb
index ef96267..ca185cb 100755
--- a/spec/unit/application/main.rb
+++ b/spec/unit/application/main.rb
@@ -140,34 +140,28 @@ describe "Puppet" do
before :each do
Puppet.stubs(:[]).with(:environment)
Puppet.stubs(:[]).with(:manifest).returns("site.pp")
- @interpreter = stub_everything
Puppet.stubs(:err)
@main.stubs(:exit)
@main.options.stubs(:[]).with(:code).returns "some code"
- Puppet::Parser::Interpreter.stubs(:new).returns(@interpreter)
+ @collection = stub_everything
+ Puppet::Parser::ResourceTypeCollection.stubs(:new).returns(@collection)
end
- it "should delegate to the Puppet Parser" do
-
- @interpreter.expects(:parser)
-
+ it "should use a Puppet Resource Type Collection to parse the file" do
+ @collection.expects(:perform_initial_import)
@main.parseonly
end
it "should exit with exit code 0 if no error" do
@main.expects(:exit).with(0)
-
@main.parseonly
end
it "should exit with exit code 1 if error" do
- @interpreter.stubs(:parser).raises(Puppet::ParseError)
-
+ @collection.stubs(:perform_initial_import).raises(Puppet::ParseError)
@main.expects(:exit).with(1)
-
@main.parseonly
end
-
end
describe "the main command" do
diff --git a/spec/unit/application/server.rb b/spec/unit/application/server.rb
index 52b8d47..ba0fcfe 100644
--- a/spec/unit/application/server.rb
+++ b/spec/unit/application/server.rb
@@ -254,47 +254,40 @@ describe "PuppetMaster" do
@server_app.get_command.should == :main
end
+
describe "the parseonly command" do
before :each do
Puppet.stubs(:[]).with(:environment)
Puppet.stubs(:[]).with(:manifest).returns("site.pp")
- @interpreter = stub_everything
Puppet.stubs(:err)
@server_app.stubs(:exit)
- Puppet::Parser::Interpreter.stubs(:new).returns(@interpreter)
+ @collection = stub_everything
+ Puppet::Parser::ResourceTypeCollection.stubs(:new).returns(@collection)
end
- it "should delegate to the Puppet Parser" do
-
- @interpreter.expects(:parser)
-
+ it "should use a Puppet Resource Type Collection to parse the file" do
+ @collection.expects(:perform_initial_import)
@server_app.parseonly
end
it "should exit with exit code 0 if no error" do
@server_app.expects(:exit).with(0)
-
@server_app.parseonly
end
it "should exit with exit code 1 if error" do
- @interpreter.stubs(:parser).raises(Puppet::ParseError)
-
+ @collection.stubs(:perform_initial_import).raises(Puppet::ParseError)
@server_app.expects(:exit).with(1)
-
@server_app.parseonly
end
-
end
describe "the compile command" do
before do
Puppet.stubs(:[]).with(:environment)
Puppet.stubs(:[]).with(:manifest).returns("site.pp")
- @interpreter = stub_everything
Puppet.stubs(:err)
@server_app.stubs(:exit)
- Puppet::Parser::Interpreter.stubs(:new).returns(@interpreter)
Puppet.features.stubs(:pson?).returns true
end
diff --git a/spec/unit/indirector/catalog/compiler.rb b/spec/unit/indirector/catalog/compiler.rb
index e2c18de..d11daaa 100755
--- a/spec/unit/indirector/catalog/compiler.rb
+++ b/spec/unit/indirector/catalog/compiler.rb
@@ -61,32 +61,9 @@ describe Puppet::Resource::Catalog::Compiler do
end
end
- describe "when creating the interpreter" do
- before do
- # This gets pretty annoying on a plane where we have no IP address
- Facter.stubs(:value).returns("whatever")
- @compiler = Puppet::Resource::Catalog::Compiler.new
- end
-
- it "should not create the interpreter until it is asked for the first time" do
- interp = mock 'interp'
- Puppet::Parser::Interpreter.expects(:new).with().returns(interp)
- @compiler.interpreter.should equal(interp)
- end
-
- it "should use the same interpreter for all compiles" do
- interp = mock 'interp'
- Puppet::Parser::Interpreter.expects(:new).with().returns(interp)
- @compiler.interpreter.should equal(interp)
- @compiler.interpreter.should equal(interp)
- end
- end
-
describe "when finding catalogs" do
before do
Facter.stubs(:value).returns("whatever")
- env = stub 'environment', :name => "yay", :modulepath => []
- Puppet::Node::Environment.stubs(:new).returns(env)
@compiler = Puppet::Resource::Catalog::Compiler.new
@name = "me"
@@ -128,17 +105,17 @@ describe Puppet::Resource::Catalog::Compiler do
proc { @compiler.find(@request) }.should raise_error(Puppet::Error)
end
- it "should pass the found node to the interpreter for compiling" do
+ it "should pass the found node to the compiler for compiling" do
Puppet::Node.expects(:find).with(@name).returns(@node)
config = mock 'config'
- @compiler.interpreter.expects(:compile).with(@node)
+ Puppet::Parser::Compiler.expects(:compile).with(@node)
@compiler.find(@request)
end
it "should extract and save any facts from the request" do
Puppet::Node.expects(:find).with(@name).returns @node
@compiler.expects(:extract_facts_from_request).with(@request)
- @compiler.interpreter.stubs(:compile)
+ Puppet::Parser::Compiler.stubs(:compile)
@compiler.find(@request)
end
@@ -147,7 +124,7 @@ describe Puppet::Resource::Catalog::Compiler do
config = mock 'config'
result = mock 'result'
- @compiler.interpreter.expects(:compile).with(@node).returns(result)
+ Puppet::Parser::Compiler.expects(:compile).returns result
@compiler.find(@request).should equal(result)
end
@@ -157,7 +134,7 @@ describe Puppet::Resource::Catalog::Compiler do
@compiler.expects(:benchmark).with do |level, message|
level == :notice and message =~ /^Compiled catalog/
end
- @compiler.interpreter.stubs(:compile).with(@node)
+ Puppet::Parser::Compiler.stubs(:compile)
@compiler.find(@request)
end
end
diff --git a/spec/unit/parser/compiler.rb b/spec/unit/parser/compiler.rb
index cf73f4d..4646f77 100755
--- a/spec/unit/parser/compiler.rb
+++ b/spec/unit/parser/compiler.rb
@@ -41,6 +41,22 @@ describe Puppet::Parser::Compiler do
@compiler.environment.stubs(:known_resource_types).returns @known_resource_types
end
+ it "should have a class method that compiles, converts, and returns a catalog" do
+ compiler = stub 'compiler'
+ Puppet::Parser::Compiler.expects(:new).with(@node).returns compiler
+ catalog = stub 'catalog'
+ compiler.expects(:compile).returns catalog
+ converted_catalog = stub 'converted_catalog'
+ catalog.expects(:to_resource).returns converted_catalog
+
+ Puppet::Parser::Compiler.compile(@node).should equal(converted_catalog)
+ end
+
+ it "should fail intelligently when a class-level compile fails" do
+ Puppet::Parser::Compiler.expects(:new).raises ArgumentError
+ lambda { Puppet::Parser::Compiler.compile(@node) }.should raise_error(Puppet::Error)
+ end
+
it "should use the node's environment as its environment" do
@compiler.environment.should equal(@node.environment)
end
diff --git a/spec/unit/parser/interpreter.rb b/spec/unit/parser/interpreter.rb
deleted file mode 100755
index 99a0a4b..0000000
--- a/spec/unit/parser/interpreter.rb
+++ /dev/null
@@ -1,128 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-describe Puppet::Parser::Interpreter do
- before do
- @interp = Puppet::Parser::Interpreter.new
- @parser = mock 'parser'
- end
-
- describe "when creating parser instances" do
- it "should create a parser with code if there is code defined in the :code setting" do
- Puppet.settings.stubs(:uninterpolated_value).with(:code, :myenv).returns("mycode")
- @parser.expects(:string=).with("mycode")
- @parser.expects(:parse)
- Puppet::Parser::Parser.expects(:new).with(:myenv).returns(@parser)
- @interp.send(:create_parser, :myenv).object_id.should equal(@parser.object_id)
- end
-
- it "should create a parser with the main manifest when the code setting is an empty string" do
- Puppet.settings.stubs(:uninterpolated_value).with(:code, :myenv).returns("")
- Puppet.settings.stubs(:value).with(:manifest, :myenv).returns("/my/file")
- @parser.expects(:parse)
- @parser.expects(:file=).with("/my/file")
- Puppet::Parser::Parser.expects(:new).with(:myenv).returns(@parser)
- @interp.send(:create_parser, :myenv).should equal(@parser)
- end
-
- it "should return nothing when new parsers fail" do
- Puppet::Parser::Parser.expects(:new).with(:myenv).raises(ArgumentError)
- proc { @interp.send(:create_parser, :myenv) }.should raise_error(Puppet::Error)
- end
-
- it "should create parsers with environment-appropriate manifests" do
- # Set our per-environment values. We can't just stub :value, because
- # it's called by too much of the rest of the code.
- text = "[env1]\nmanifest = /t/env1.pp\n[env2]\nmanifest = /t/env2.pp"
- FileTest.stubs(:exist?).returns true
- Puppet.settings.stubs(:read_file).returns(text)
- Puppet.settings.parse
-
- parser1 = mock 'parser1'
- Puppet::Parser::Parser.expects(:new).with(:env1).returns(parser1)
- parser1.expects(:file=).with("/t/env1.pp")
- parser1.expects(:parse)
- @interp.send(:create_parser, :env1)
-
- parser2 = mock 'parser2'
- Puppet::Parser::Parser.expects(:new).with(:env2).returns(parser2)
- parser2.expects(:file=).with("/t/env2.pp")
- parser2.expects(:parse)
- @interp.send(:create_parser, :env2)
- end
- end
-
- describe "when managing parser instances" do
- it "should use the same parser when the parser does not need reparsing" do
- @interp.expects(:create_parser).with(:myenv).returns(@parser)
- @interp.send(:parser, :myenv).should equal(@parser)
-
- @parser.expects(:reparse?).returns(false)
- @interp.send(:parser, :myenv).should equal(@parser)
- end
-
- it "should fail intelligently if a parser cannot be created and one does not already exist" do
- @interp.expects(:create_parser).with(:myenv).raises(ArgumentError)
- proc { @interp.send(:parser, :myenv) }.should raise_error(ArgumentError)
- end
-
- it "should use different parsers for different environments" do
- # get one for the first env
- @interp.expects(:create_parser).with(:first_env).returns(@parser)
- @interp.send(:parser, :first_env).should equal(@parser)
-
- other_parser = mock('otherparser')
- @interp.expects(:create_parser).with(:second_env).returns(other_parser)
- @interp.send(:parser, :second_env).should equal(other_parser)
- end
-
- describe "when files need reparsing" do
- it "should create a new parser" do
- oldparser = mock('oldparser')
- newparser = mock('newparser')
- oldparser.expects(:reparse?).returns(true)
-
- @interp.expects(:create_parser).with(:myenv).returns(oldparser)
- @interp.send(:parser, :myenv).should equal(oldparser)
- @interp.expects(:create_parser).with(:myenv).returns(newparser)
- @interp.send(:parser, :myenv).should equal(newparser)
- end
-
- it "should raise an exception if a new parser cannot be created" do
- # Get the first parser in the hash.
- @interp.expects(:create_parser).with(:myenv).returns(@parser)
- @interp.send(:parser, :myenv).should equal(@parser)
-
- @parser.expects(:reparse?).returns(true)
-
- @interp.expects(:create_parser).with(:myenv).raises(Puppet::Error, "Could not parse")
-
- lambda { @interp.parser(:myenv) }.should raise_error(Puppet::Error)
- end
- end
- end
-
- describe "when compiling a catalog" do
- before do
- @node = Puppet::Node.new("foo")
- @compiler = mock 'compile'
- end
-
- it "should create a compile with the node" do
- catalog = stub 'catalog', :to_resource => nil
- @compiler.expects(:compile).returns(catalog)
- Puppet::Parser::Compiler.expects(:new).with(@node).returns(@compiler)
- @interp.compile(@node)
- end
-
- it "should return the results of the compile, converted to a plain resource catalog" do
- catalog = mock 'catalog'
- @compiler.expects(:compile).returns(catalog)
- Puppet::Parser::Compiler.stubs(:new).returns(@compiler)
-
- catalog.expects(:to_resource).returns "my_resource_catalog"
- @interp.compile(@node).should == "my_resource_catalog"
- end
- end
-end
diff --git a/spec/unit/resource/catalog.rb b/spec/unit/resource/catalog.rb
index 7f30491..e2fe724 100755
--- a/spec/unit/resource/catalog.rb
+++ b/spec/unit/resource/catalog.rb
@@ -100,9 +100,8 @@ describe Puppet::Resource::Catalog, "when compiling" do
describe "when extracting transobjects" do
def mkscope
- @parser = Puppet::Parser::Parser.new :Code => ""
@node = Puppet::Node.new("mynode")
- @compiler = Puppet::Parser::Compiler.new(@node, @parser)
+ @compiler = Puppet::Parser::Compiler.new(@node)
# XXX This is ridiculous.
@compiler.send(:evaluate_main)
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list