test/language/parser.rb in puppet-0.24.1 vs test/language/parser.rb in puppet-0.24.2

- old
+ new

@@ -43,13 +43,13 @@ parser = mkparser Puppet.debug("parsing failer %s" % file) if __FILE__ == $0 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 :scope => config.topscope + #ast.classes[""].evaluate config.topscope } Puppet::Type.allclear } end @@ -866,11 +866,11 @@ assert_equal("other::mydefine", other.classname) end def test_newclass scope = mkscope - parser = scope.compile.parser + parser = scope.compiler.parser mkcode = proc do |ary| classes = ary.collect do |string| AST::FlatString.new(:value => string) end @@ -889,21 +889,21 @@ assert(klass, "Did not return class") assert(parser.classes["myclass"], "Could not find definition") assert_equal("myclass", parser.classes["myclass"].classname) assert_equal(%w{original code}, - parser.classes["myclass"].code.evaluate(:scope => scope)) + parser.classes["myclass"].code.evaluate(scope)) # Newclass behaves differently than the others -- it just appends # the code to the existing class. code = mkcode.call(%w{something new}) assert_nothing_raised do klass = parser.newclass("myclass", :code => code) end assert(klass, "Did not return class when appending") assert_equal(%w{original code something new}, - parser.classes["myclass"].code.evaluate(:scope => scope)) + parser.classes["myclass"].code.evaluate(scope)) # Now create the same class name in a different scope assert_nothing_raised { klass = parser.newclass("other::myclass", :code => mkcode.call(%w{something diff})) @@ -912,33 +912,33 @@ other = parser.classes["other::myclass"] assert(other, "Could not find class") assert_equal("other::myclass", other.classname) assert_equal("other::myclass", other.namespace) assert_equal(%w{something diff}, - other.code.evaluate(:scope => scope)) + other.code.evaluate(scope)) # Make sure newclass deals correctly with nodes with no code klass = parser.newclass("nocode") assert(klass, "Did not return class") assert_nothing_raised do klass = parser.newclass("nocode", :code => mkcode.call(%w{yay test})) end assert(klass, "Did not return class with no code") assert_equal(%w{yay test}, - parser.classes["nocode"].code.evaluate(:scope => scope)) + parser.classes["nocode"].code.evaluate(scope)) # Then try merging something into nothing parser.newclass("nocode2", :code => mkcode.call(%w{foo test})) assert(klass, "Did not return class with no code") assert_nothing_raised do klass = parser.newclass("nocode2") end assert(klass, "Did not return class with no code") assert_equal(%w{foo test}, - parser.classes["nocode2"].code.evaluate(:scope => scope)) + parser.classes["nocode2"].code.evaluate(scope)) # And lastly, nothing and nothing klass = parser.newclass("nocode3") assert(klass, "Did not return class with no code") @@ -1185,8 +1185,20 @@ assert_nothing_raised do result = parser.newdefine "FunTest" end assert_equal(result, parser.finddefine("", "fUntEst"), "%s was not matched" % "fUntEst") + end + + def test_manifests_with_multiple_environments + parser = mkparser :environment => "something" + + # We use an exception to cut short the processing to simplify our stubbing + #Puppet::Module.expects(:find_manifests).with("test", {:cwd => ".", :environment => "something"}).raises(Puppet::ParseError) + Puppet::Module.expects(:find_manifests).with("test", {:cwd => ".", :environment => "something"}).returns([]) + + assert_raise(Puppet::ImportError) do + parser.import("test") + end end end