summaryrefslogtreecommitdiffstats
path: root/spec/integration/parser
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-08-17 12:02:05 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-08-17 12:25:37 -0700
commit16f701edd89a320ad73b5468d883dfb017fe6e96 (patch)
tree0063bdd34139f0ba09be638f8eabf4bf0e596008 /spec/integration/parser
parent3c090de39897d85a5d5be20254efcddea14ad8ad (diff)
parent4da88fb4cd57871f16649d50572240ac3f7420f0 (diff)
downloadpuppet-16f701edd89a320ad73b5468d883dfb017fe6e96.tar.gz
puppet-16f701edd89a320ad73b5468d883dfb017fe6e96.tar.xz
puppet-16f701edd89a320ad73b5468d883dfb017fe6e96.zip
Merge remote branch 'paul/4472-4483-4496-4521-4522'
a.k.a. "make_taller_trees"
Diffstat (limited to 'spec/integration/parser')
-rwxr-xr-xspec/integration/parser/collector_spec.rb2
-rwxr-xr-xspec/integration/parser/compiler_spec.rb22
-rwxr-xr-xspec/integration/parser/parser_spec.rb8
3 files changed, 28 insertions, 4 deletions
diff --git a/spec/integration/parser/collector_spec.rb b/spec/integration/parser/collector_spec.rb
index 73273c909..b1cfc51c7 100755
--- a/spec/integration/parser/collector_spec.rb
+++ b/spec/integration/parser/collector_spec.rb
@@ -17,7 +17,7 @@ describe Puppet::Parser::Collector do
def query(text)
code = "File <| #{text} |>"
parser = Puppet::Parser::Parser.new(@scope.compiler)
- parser.parse(code).hostclass("").code[0].query
+ return parser.parse(code).code[0].query
end
{true => [%{title == "/tmp/testing"}, %{(title == "/tmp/testing")}, %{group == bin},
diff --git a/spec/integration/parser/compiler_spec.rb b/spec/integration/parser/compiler_spec.rb
index 9158ad1c2..266347c60 100755
--- a/spec/integration/parser/compiler_spec.rb
+++ b/spec/integration/parser/compiler_spec.rb
@@ -69,4 +69,26 @@ describe Puppet::Parser::Compiler do
notify_resource[:require].title.should == "Experiment::Baz"
end
end
+
+ it "should recompute the version after input files are re-parsed" do
+ Puppet[:code] = 'class foo { }'
+ Time.stubs(:now).returns(1)
+ node = Puppet::Node.new('mynode')
+ Puppet::Parser::Compiler.compile(node).version.should == 1
+ Time.stubs(:now).returns(2)
+ Puppet::Parser::Compiler.compile(node).version.should == 1 # no change because files didn't change
+ Puppet::Resource::TypeCollection.any_instance.stubs(:stale?).returns(true).then.returns(false) # pretend change
+ Puppet::Parser::Compiler.compile(node).version.should == 2
+ end
+
+ it "should not allow classes inside conditional constructs" do
+ Puppet[:code] = <<-PP
+ if true {
+ class foo {
+ }
+ }
+ PP
+
+ lambda { Puppet::Parser::Compiler.compile(Puppet::Node.new("mynode")) }.should raise_error(Puppet::Error)
+ end
end
diff --git a/spec/integration/parser/parser_spec.rb b/spec/integration/parser/parser_spec.rb
index 7b85bcacb..0d9aa51e1 100755
--- a/spec/integration/parser/parser_spec.rb
+++ b/spec/integration/parser/parser_spec.rb
@@ -11,7 +11,7 @@ describe Puppet::Parser::Parser do
end
def result_instance
- @result.hostclass("").code[0]
+ @result.code[0]
end
def matches?(string)
@@ -44,7 +44,7 @@ describe Puppet::Parser::Parser do
end
def result_instance
- @result.hostclass("").code[0]
+ @result.code[0]
end
def matches?(string)
@@ -85,7 +85,9 @@ describe Puppet::Parser::Parser do
class test {}
""")
- ast.hostclass("test").doc.should == "comment\n"
+ ast.code[0].should be_a(Puppet::Parser::AST::Hostclass)
+ ast.code[0].name.should == 'test'
+ ast.code[0].instantiate('')[0].doc.should == "comment\n"
end
end