summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-11-03 19:58:38 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-11-03 19:59:37 -0700
commit9e2a0e41dfb253a19180aeea6b66f65ca8d63133 (patch)
treef102b396669c074b59eab5c2e59c5145b5bae6ab /test
parentb1ef091d0209a59ac747568f83416e992db93ea8 (diff)
parent85543a41978924a42490d0c3f1f5437c95b7c869 (diff)
downloadpuppet-9e2a0e41dfb253a19180aeea6b66f65ca8d63133.tar.gz
puppet-9e2a0e41dfb253a19180aeea6b66f65ca8d63133.tar.xz
puppet-9e2a0e41dfb253a19180aeea6b66f65ca8d63133.zip
Merge commit '85543a4'
This updates `master` to the pre-agile-iteration state.
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/functions.rb2
-rwxr-xr-xtest/language/parser.rb81
-rwxr-xr-xtest/language/scope.rb6
-rw-r--r--test/lib/puppettest/parsertesting.rb13
-rwxr-xr-xtest/other/report.rb7
-rwxr-xr-xtest/rails/railsparameter.rb2
-rwxr-xr-xtest/ral/providers/cron/crontab.rb5
-rwxr-xr-xtest/util/metrics.rb4
8 files changed, 55 insertions, 65 deletions
diff --git a/test/language/functions.rb b/test/language/functions.rb
index 1d4ed8241..081063e2b 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -451,7 +451,7 @@ class TestLangFunctions < Test::Unit::TestCase
scope.function_include("nosuchclass")
end
- parser.newclass("myclass")
+ scope.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "myclass", {})
scope.compiler.expects(:evaluate_classes).with(%w{myclass otherclass}, scope, false).returns(%w{myclass otherclass})
diff --git a/test/language/parser.rb b/test/language/parser.rb
index 8cda8eeb2..6f3d751c2 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -39,9 +39,8 @@ class TestParser < Test::Unit::TestCase
failers { |file|
parser = mkparser
Puppet.debug("parsing failer #{file}") if __FILE__ == $0
- assert_raise(Puppet::ParseError, "Did not fail while parsing #{file}") {
- parser.file = file
- ast = parser.parse
+ assert_raise(Puppet::ParseError, Puppet::Error, "Did not fail while parsing #{file}") {
+ Puppet[:manifest] = file
config = mkcompiler(parser)
config.compile
#ast.hostclass("").evaluate config.topscope
@@ -288,7 +287,7 @@ class TestParser < Test::Unit::TestCase
ret = parser.parse
}
- ret.hostclass("").code.each do |obj|
+ ret.code.each do |obj|
assert_instance_of(AST::Collection, obj)
end
end
@@ -362,12 +361,12 @@ file { "/tmp/yayness":
assert_raise(Puppet::ParseError) {
- parser.parse %{define mydef($schedule) {}}
+ parser.known_resource_types.import_ast(parser.parse(%{define mydef($schedule) {}}), '')
}
assert_nothing_raised {
- parser.parse %{define adef($schedule = false) {}}
- parser.parse %{define mydef($schedule = daily) {}}
+ parser.known_resource_types.import_ast(parser.parse(%{define adef($schedule = false) {}}), '')
+ parser.known_resource_types.import_ast(parser.parse(%{define mydef($schedule = daily) {}}), '')
}
end
@@ -379,12 +378,12 @@ file { "/tmp/yayness":
str1 = %{if true { #{exec.call("true")} }}
ret = nil
assert_nothing_raised {
- ret = parser.parse(str1).hostclass("").code[0]
+ ret = parser.parse(str1).code[0]
}
assert_instance_of(Puppet::Parser::AST::IfStatement, ret)
parser = mkparser
str2 = %{if true { #{exec.call("true")} } else { #{exec.call("false")} }}
- ret = parser.parse(str2).hostclass("").code[0]
+ ret = parser.parse(str2).code[0]
assert_instance_of(Puppet::Parser::AST::IfStatement, ret)
assert_instance_of(Puppet::Parser::AST::Else, ret.else)
end
@@ -393,23 +392,23 @@ file { "/tmp/yayness":
parser = mkparser
assert_nothing_raised {
- parser.parse %{class myclass { class other {} }}
+ parser.known_resource_types.import_ast(parser.parse(%{class myclass { class other {} }}), '')
}
assert(parser.hostclass("myclass"), "Could not find myclass")
assert(parser.hostclass("myclass::other"), "Could not find myclass::other")
assert_nothing_raised {
- parser.parse "class base {}
+ parser.known_resource_types.import_ast(parser.parse("class base {}
class container {
class deep::sub inherits base {}
- }"
+ }"), '')
}
sub = parser.hostclass("container::deep::sub")
assert(sub, "Could not find sub")
# Now try it with a parent class being a fq class
assert_nothing_raised {
- parser.parse "class container::one inherits container::deep::sub {}"
+ parser.known_resource_types.import_ast(parser.parse("class container::one inherits container::deep::sub {}"), '')
}
sub = parser.hostclass("container::one")
assert(sub, "Could not find one")
@@ -417,7 +416,7 @@ file { "/tmp/yayness":
# Finally, try including a qualified class
assert_nothing_raised("Could not include fully qualified class") {
- parser.parse "include container::deep::sub"
+ parser.known_resource_types.import_ast(parser.parse("include container::deep::sub"), '')
}
end
@@ -426,20 +425,11 @@ file { "/tmp/yayness":
# Make sure we put the top-level code into a class called "" in
# the "" namespace
- assert_nothing_raised do
- out = parser.parse ""
-
- assert_instance_of(Puppet::Resource::TypeCollection, out)
- assert_nil(parser.hostclass(""), "Got a 'main' class when we had no code")
- end
-
- # Now try something a touch more complicated
parser.initvars
assert_nothing_raised do
- out = parser.parse "Exec { path => '/usr/bin:/usr/sbin' }"
- assert_instance_of(Puppet::Resource::TypeCollection, out)
- assert_equal("", parser.hostclass("").name)
- assert_equal("", parser.hostclass("").namespace)
+ parser.known_resource_types.import_ast(parser.parse("Exec { path => '/usr/bin:/usr/sbin' }"), '')
+ assert_equal("", parser.known_resource_types.hostclass("").name)
+ assert_equal("", parser.known_resource_types.hostclass("").namespace)
end
end
@@ -482,22 +472,26 @@ file { "/tmp/yayness":
ret = nil
assert_nothing_raised do
- ret = parser.parse("#{at}file { '/tmp/testing': owner => root }")
+ parser.known_resource_types.import_ast(parser.parse("#{at}file { '/tmp/testing': owner => root }"), '')
+ ret = parser.known_resource_types
end
assert_instance_of(AST::ASTArray, ret.hostclass("").code)
resdef = ret.hostclass("").code[0]
assert_instance_of(AST::Resource, resdef)
- assert_equal("/tmp/testing", resdef.title.value)
+ assert_instance_of(AST::ASTArray, resdef.instances)
+ assert_equal(1, resdef.instances.children.length)
+ assert_equal("/tmp/testing", resdef.instances[0].title.value)
# We always get an astarray back, so...
check.call(resdef, "simple resource")
# Now let's try it with multiple resources in the same spec
assert_nothing_raised do
- ret = parser.parse("#{at}file { ['/tmp/1', '/tmp/2']: owner => root }")
+ parser.known_resource_types.import_ast(parser.parse("#{at}file { ['/tmp/1', '/tmp/2']: owner => root }"), '')
+ ret = parser.known_resource_types
end
- ret.hostclass("").code.each do |res|
+ ret.hostclass("").code[0].each do |res|
assert_instance_of(AST::Resource, res)
check.call(res, "multiresource")
end
@@ -537,7 +531,7 @@ file { "/tmp/yayness":
ret = parser.parse("File #{arrow}")
end
- coll = ret.hostclass("").code[0]
+ coll = ret.code[0]
assert_instance_of(AST::Collection, coll)
assert_equal(form, coll.form)
end
@@ -560,7 +554,7 @@ file { "/tmp/yayness":
res = nil
assert_nothing_raised do
- res = parser.parse(str).hostclass("").code[0]
+ res = parser.parse(str).code[0]
end
assert_instance_of(AST::Collection, res)
@@ -583,7 +577,7 @@ file { "/tmp/yayness":
res = nil
assert_nothing_raised do
- res = parser.parse(str).hostclass("").code[0]
+ res = parser.parse(str).code[0]
end
assert_instance_of(AST::Collection, res)
@@ -607,7 +601,7 @@ file { "/tmp/yayness":
res = nil
assert_nothing_raised("Could not parse '#{test}'") do
- res = parser.parse(str).hostclass("").code[0]
+ res = parser.parse(str).code[0]
end
assert_instance_of(AST::Collection, res)
@@ -624,15 +618,11 @@ file { "/tmp/yayness":
def test_fully_qualified_definitions
parser = mkparser
+ types = parser.known_resource_types
assert_nothing_raised("Could not parse fully-qualified definition") {
- parser.parse %{define one::two { }}
+ types.import_ast(parser.parse(%{define one::two { }}), '')
}
assert(parser.definition("one::two"), "Could not find one::two with no namespace")
-
- # Now try using the definition
- assert_nothing_raised("Could not parse fully-qualified definition usage") {
- parser.parse %{one::two { yayness: }}
- }
end
# #524
@@ -691,7 +681,7 @@ file { "/tmp/yayness":
result = parser.parse %{$variable = undef}
}
- main = result.hostclass("").code
+ main = result.code
children = main.children
assert_instance_of(AST::VarDef, main.children[0])
assert_instance_of(AST::Undef, main.children[0].value)
@@ -704,7 +694,8 @@ file { "/tmp/yayness":
str = "file { '/tmp/yay': ensure => file }\nclass yay {}\nnode foo {}\ndefine bar {}\n"
result = nil
assert_nothing_raised("Could not parse") do
- result = parser.parse(str)
+ parser.known_resource_types.import_ast(parser.parse(str), '')
+ result = parser.known_resource_types
end
assert_instance_of(Puppet::Resource::TypeCollection, result, "Did not get a ASTSet back from parsing")
@@ -734,12 +725,14 @@ file { "/tmp/yayness":
result = nil
assert_nothing_raised do
- result = parser.newclass "Yayness"
+ parser.known_resource_types.import_ast(parser.parse("class yayness { }"), '')
+ result = parser.known_resource_types.hostclass('yayness')
end
assert_equal(result, parser.find_hostclass("", "yayNess"))
assert_nothing_raised do
- result = parser.newdefine "FunTest"
+ parser.known_resource_types.import_ast(parser.parse("define funtest { }"), '')
+ result = parser.known_resource_types.definition('funtest')
end
assert_equal(result, parser.find_definition("", "fUntEst"), "#{"fUntEst"} was not matched")
end
diff --git a/test/language/scope.rb b/test/language/scope.rb
index cb5558aec..d9c122a92 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -163,7 +163,7 @@ class TestScope < Test::Unit::TestCase
config = mkcompiler
# Create a default source
- parser.newclass("")
+ parser.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "")
config.topscope.source = parser.known_resource_types.hostclass("")
# And a scope resource
@@ -175,12 +175,12 @@ class TestScope < Test::Unit::TestCase
)
# Create a top-level define
- parser.newdefine "one", :arguments => [%w{arg}],
+ parser.known_resource_types.add Puppet::Resource::Type.new(:definition, "one", :arguments => [%w{arg}],
:code => AST::ASTArray.new(
:children => [
resourcedef("file", "/tmp", {"owner" => varref("arg")})
]
- )
+ ))
# create a resource that calls our third define
obj = resourcedef("one", "boo", {"arg" => "parentfoo"})
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb
index bd04c1ec5..411bad37a 100644
--- a/test/lib/puppettest/parsertesting.rb
+++ b/test/lib/puppettest/parsertesting.rb
@@ -94,16 +94,15 @@ module PuppetTest::ParserTesting
def resourcedef(type, title, params)
title = stringobj(title) unless title.is_a?(AST)
+ instance = AST::ResourceInstance.new(:title => title, :parameters => resourceparams(params))
assert_nothing_raised("Could not create #{type} #{title}") {
return AST::Resource.new(
:file => __FILE__,
:line => __LINE__,
- :title => title,
:type => type,
-
- :parameters => resourceinst(params)
+ :instances => AST::ASTArray.new(:children => [instance])
)
}
end
@@ -122,9 +121,7 @@ module PuppetTest::ParserTesting
:file => __FILE__,
:line => __LINE__,
:object => resourceref(type, title),
-
- :type => type,
- :parameters => resourceinst(params)
+ :parameters => resourceparams(params)
)
}
end
@@ -197,13 +194,13 @@ module PuppetTest::ParserTesting
}
end
- def resourceinst(hash)
+ def resourceparams(hash)
assert_nothing_raised("Could not create resource instance") {
params = hash.collect { |param, value|
resourceparam(param, value)
}
- return AST::ResourceInstance.new(
+ return AST::ASTArray.new(
:file => tempfile,
diff --git a/test/other/report.rb b/test/other/report.rb
index b3b41da19..8a909b41c 100755
--- a/test/other/report.rb
+++ b/test/other/report.rb
@@ -35,10 +35,7 @@ class TestReports < Test::Unit::TestCase
config.retrieval_duration = 0.001
trans = config.apply
- report = Puppet::Transaction::Report.new
- trans.add_metrics_to_report(report)
-
- report
+ trans.generate_report
end
# Make sure we can use reports as log destinations.
@@ -95,7 +92,7 @@ class TestReports < Test::Unit::TestCase
assert_equal(yaml, File.read(file), "File did not get written")
end
- if Puppet.features.rrd?
+ if Puppet.features.rrd? || Puppet.features.rrd_legacy?
def test_rrdgraph_report
Puppet.settings.use(:main, :metrics)
report = mkreport
diff --git a/test/rails/railsparameter.rb b/test/rails/railsparameter.rb
index 9f6fc1c1e..77ce33912 100755
--- a/test/rails/railsparameter.rb
+++ b/test/rails/railsparameter.rb
@@ -22,7 +22,7 @@ class TestRailsParameter < Test::Unit::TestCase
# Now create a source
parser = mkparser
- source = parser.newclass "myclass"
+ source = parser.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "myclass")
host = Puppet::Rails::Host.new(:name => "myhost")
diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb
index 0c87a5bba..be2af1e16 100755
--- a/test/ral/providers/cron/crontab.rb
+++ b/test/ral/providers/cron/crontab.rb
@@ -97,7 +97,10 @@ class TestCronParsedProvider < Test::Unit::TestCase
# Then do them all at once.
records = []
text = ""
- sample_records.each do |name, options|
+ # Sort sample_records so that the :empty entry does not come last
+ # (if it does, the test will fail because the empty last line will
+ # be ignored)
+ sample_records.sort { |a, b| a.first.to_s <=> b.first.to_s }.each do |name, options|
records << options[:record]
text += options[:text] + "\n"
end
diff --git a/test/util/metrics.rb b/test/util/metrics.rb
index 1fd57f2f1..82e792d0b 100755
--- a/test/util/metrics.rb
+++ b/test/util/metrics.rb
@@ -8,7 +8,7 @@ require 'puppettest'
require 'puppet/type'
class TestMetric < PuppetTest::TestCase
- confine "Missing RRDtool library" => Puppet.features.rrd?
+ confine "Missing RRDtool library" => (Puppet.features.rrd? || Puppet.features.rrd_legacy?)
include PuppetTest
def gendata
@@ -43,7 +43,7 @@ class TestMetric < PuppetTest::TestCase
def rundata(report, time)
assert_nothing_raised {
gendata.each do |name, data|
- report.newmetric(name, data)
+ report.add_metric(name, data)
end
report.metrics.each { |n, m| m.store(time) }
}