summaryrefslogtreecommitdiffstats
path: root/test/parser/tc_parser.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-23 20:42:08 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-23 20:42:08 +0000
commit8211df036e1d2d24e1084616fc3fc4891b06cfdd (patch)
tree597f8b999cf5210a7ceff5ef1e1977f1de08c241 /test/parser/tc_parser.rb
parentd20ac8e0b564e5413d571f2059de559e0783b72d (diff)
downloadpuppet-8211df036e1d2d24e1084616fc3fc4891b06cfdd.tar.gz
puppet-8211df036e1d2d24e1084616fc3fc4891b06cfdd.tar.xz
puppet-8211df036e1d2d24e1084616fc3fc4891b06cfdd.zip
Many, many changes toward a completely functional system. The only current problems with my home config are that apache's stupid init script does not do status and that packages are not working as non-root users (which makes sense).
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@703 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/parser/tc_parser.rb')
-rw-r--r--test/parser/tc_parser.rb116
1 files changed, 116 insertions, 0 deletions
diff --git a/test/parser/tc_parser.rb b/test/parser/tc_parser.rb
index de2d75ddc..4e3d83a63 100644
--- a/test/parser/tc_parser.rb
+++ b/test/parser/tc_parser.rb
@@ -58,6 +58,122 @@ class TestParser < TestPuppet
ret = parser.parse
}
end
+
+ def mkmanifest(file)
+ name = File.join(tmpdir, "file%s" % rand(100))
+ @@tmpfiles << name
+
+ File.open(file, "w") { |f|
+ f.puts "file { \"%s\": create => true, mode => 755 }\n" %
+ name
+ }
+ end
+
+ def test_importglobbing
+ basedir = File.join(tmpdir(), "importesting")
+ @@tmpfiles << basedir
+ Dir.mkdir(basedir)
+
+ subdir = "subdir"
+ Dir.mkdir(File.join(basedir, subdir))
+ manifest = File.join(basedir, "manifest")
+ File.open(manifest, "w") { |f|
+ f.puts "import \"%s/*\"" % subdir
+ }
+
+ 4.times { |i|
+ path = File.join(basedir, subdir, "subfile%s" % i)
+ mkmanifest(path)
+ }
+
+ assert_nothing_raised("Could not parse multiple files") {
+ parser = Puppet::Parser::Parser.new()
+ parser.file = manifest
+ parser.parse
+ }
+ end
+
+ def test_zdefaults
+ basedir = File.join(tmpdir(), "defaulttesting")
+ @@tmpfiles << basedir
+ Dir.mkdir(basedir)
+
+ defs1 = {
+ "testing" => "value"
+ }
+
+ defs2 = {
+ "one" => "two",
+ "three" => "four",
+ "five" => false,
+ "seven" => "eight",
+ "nine" => true,
+ "eleven" => "twelve"
+ }
+
+ mkdef = proc { |hash|
+ hash.collect { |arg, value|
+ "%s = %s" % [arg, value]
+ }.join(", ")
+ }
+ manifest = File.join(basedir, "manifest")
+ File.open(manifest, "w") { |f|
+ f.puts "
+ define method(#{mkdef.call(defs1)}, other) {
+ $variable = $testing
+ }
+
+ define othermethod(#{mkdef.call(defs2)}, goodness) {
+ $more = less
+ }
+
+ method {
+ other => yayness
+ }
+
+ othermethod {
+ goodness => rahness
+ }
+"
+ }
+
+ ast = nil
+ assert_nothing_raised("Could not parse multiple files") {
+ parser = Puppet::Parser::Parser.new()
+ parser.file = manifest
+ ast = parser.parse
+ }
+
+ assert(ast, "Did not receive AST while parsing defaults")
+
+ scope = nil
+ assert_nothing_raised("Could not evaluate defaults parse tree") {
+ scope = Puppet::Parser::Scope.new()
+ objects = scope.evaluate(ast)
+ }
+
+ method = nil
+ othermethod = nil
+ assert_nothing_raised {
+ method = scope.find { |child|
+ child.is_a?(Puppet::Parser::Scope) and child.type == "method"
+ }
+ defs1.each { |var, value|
+ curval = method.lookupvar(var)
+ assert_equal(value, curval, "Did not get default")
+ }
+ }
+
+ assert_nothing_raised {
+ method = scope.find { |child|
+ child.is_a?(Puppet::Parser::Scope) and child.type == "othermethod"
+ }
+ defs2.each { |var, value|
+ curval = method.lookupvar(var)
+ assert_equal(value, curval, "Did not get default")
+ }
+ }
+ end
end
# $Id$