summaryrefslogtreecommitdiffstats
path: root/test/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-01-29 20:57:21 -0600
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit7089446697ad550c22012bc2b5572030727d67e1 (patch)
tree40d160f11839fe6e20311186ded4e621d23e1242 /test/lib
parent4871c909cd28c82b64d0b62d8a27e62737d8733d (diff)
downloadpuppet-7089446697ad550c22012bc2b5572030727d67e1.tar.gz
puppet-7089446697ad550c22012bc2b5572030727d67e1.tar.xz
puppet-7089446697ad550c22012bc2b5572030727d67e1.zip
Removing Resource::Reference classes
This commit is hopefully less messy than it first appears, but it's certainly cross-cutting. The reason for all of this is that we previously only looked up builtin resource types from outside the parser, but now that the defined resource types are available globally via environments, we can push that lookup code to Resource. Once we do that, however, we have to have environment and namespace information in every resource. Here I remove the Resource::Reference classes (except the AST class), and use Resource instances instead. I did this because the shared code between the two classes got incredibly complicated, such that they should have had a hierarchical relationship disallowed by their constants. This complexity convinced me just to get rid of References entirely. I also make Puppet::Parser::Resource a subclass of Puppet::Resource. There are still broken tests in test/, but this was a big enough commit I wanted to get it in. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/puppettest/parsertesting.rb17
-rw-r--r--test/lib/puppettest/resourcetesting.rb11
2 files changed, 12 insertions, 16 deletions
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb
index dee38eb3a..44c78f2c3 100644
--- a/test/lib/puppettest/parsertesting.rb
+++ b/test/lib/puppettest/parsertesting.rb
@@ -47,9 +47,8 @@ module PuppetTest::ParserTesting
end
def mkcompiler(parser = nil)
- parser ||= mkparser
node = mknode
- return Compiler.new(node, parser)
+ return Compiler.new(node)
end
def mknode(name = nil)
@@ -59,12 +58,9 @@ module PuppetTest::ParserTesting
Puppet::Node.new(name)
end
- def mkinterp
- Puppet::Parser::Interpreter.new
- end
-
- def mkparser(args = {})
- Puppet::Parser::Parser.new(args)
+ def mkparser
+ Puppet::Node::Environment.clear
+ Puppet::Parser::Parser.new(Puppet::Node::Environment.new)
end
def mkscope(hash = {})
@@ -306,13 +302,10 @@ module PuppetTest::ParserTesting
interp = nil
oldmanifest = Puppet[:manifest]
Puppet[:manifest] = manifest
- assert_nothing_raised {
- interp = Puppet::Parser::Interpreter.new
- }
trans = nil
assert_nothing_raised {
- trans = interp.compile(mknode)
+ trans = Puppet::Parser::Compiler.new(mknode).compile
}
config = nil
diff --git a/test/lib/puppettest/resourcetesting.rb b/test/lib/puppettest/resourcetesting.rb
index d4469a203..95fe5bcb7 100644
--- a/test/lib/puppettest/resourcetesting.rb
+++ b/test/lib/puppettest/resourcetesting.rb
@@ -15,9 +15,12 @@ module PuppetTest::ResourceTesting
args[:source] ||= "source"
args[:scope] ||= mkscope
- {:type => "resource", :title => "testing",
- :source => "source", :scope => "scope"}.each do |param, value|
- args[param] ||= value
+ type = args[:type] || "resource"
+ title = args[:title] || "testing"
+ args.delete(:type)
+ args.delete(:title)
+ {:source => "source", :scope => "scope"}.each do |param, value|
+ args[param] ||= value
end
params = args[:params] || {:one => "yay", :three => "rah"}
@@ -27,7 +30,7 @@ module PuppetTest::ResourceTesting
args[:params] = paramify args[:source], params
end
- Parser::Resource.new(args)
+ Parser::Resource.new(type, title, args)
end
def param(name, value, source)