summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-27 22:21:44 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-27 22:21:44 +0000
commit8c821c09eebe117bd8b100b6dc416ded0588b979 (patch)
treeaacd4fb7d966eae215917e5556e9e08eeb43bc53 /test
parent37c10d176d8d3b7bb1920bbda66c6f0429b66730 (diff)
downloadpuppet-8c821c09eebe117bd8b100b6dc416ded0588b979.tar.gz
puppet-8c821c09eebe117bd8b100b6dc416ded0588b979.tar.xz
puppet-8c821c09eebe117bd8b100b6dc416ded0588b979.zip
Mostly, this is a refactoring commit. There is one significant new feature,
though: overrides now only work within a class heirarchy, which is to say that a subclass can override an element in a base class, but a child scope cannot otherwise override an element in a base scope. I've also done a good bit of refactoring, though; notably, AST#evaluate now takes named arguments, and I changed the 'name' parameter to 'type' in all of the Component classes (this was all internal, but was confusing as it was). I also removed the need for the autonaming stuff -- it's now acceptable for components not to have names, and everything behaves correctly. I haven't yet removed the autoname code, though; I'll do that on the next commit. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@952 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/executables/puppetmasterd.rb1
-rwxr-xr-xtest/language/ast.rb36
-rwxr-xr-xtest/language/scope.rb36
-rw-r--r--test/parser/parser.rb5
-rw-r--r--test/puppettest.rb4
-rw-r--r--test/tagging/tagging.rb10
-rwxr-xr-xtest/test3
-rw-r--r--test/types/query.rb4
8 files changed, 54 insertions, 45 deletions
diff --git a/test/executables/puppetmasterd.rb b/test/executables/puppetmasterd.rb
index 691e27070..cbf8ac02a 100755
--- a/test/executables/puppetmasterd.rb
+++ b/test/executables/puppetmasterd.rb
@@ -92,6 +92,7 @@ class TestPuppetMasterD < Test::Unit::TestCase
pid = nil
ps = Facter["ps"].value || "ps -ef"
%x{#{ps}}.chomp.split(/\n/).each { |line|
+ next if line =~ /^puppet/ # skip normal master procs
if line =~ /puppetmasterd.+--manifest/
ary = line.split(" ")
pid = ary[1].to_i
diff --git a/test/language/ast.rb b/test/language/ast.rb
index c4fe67975..fa7d8a651 100755
--- a/test/language/ast.rb
+++ b/test/language/ast.rb
@@ -54,7 +54,7 @@ class TestAST < Test::Unit::TestCase
scope = nil
assert_nothing_raised("Could not evaluate") {
scope = Puppet::Parser::Scope.new()
- objects = top.evaluate(scope)
+ objects = top.evaluate(:scope => scope)
}
assert_equal(1, scope.find_all { |child|
@@ -78,7 +78,7 @@ class TestAST < Test::Unit::TestCase
scope = Puppet::Parser::Scope.new()
assert_nothing_raised("Could not evaluate") {
- top.evaluate(scope)
+ top.evaluate(:scope => scope)
}
obj = nil
@@ -124,7 +124,7 @@ class TestAST < Test::Unit::TestCase
scope = nil
assert_raise(Puppet::ParseError, "Invalid parent type was allowed") {
scope = Puppet::Parser::Scope.new()
- objects = top.evaluate(scope)
+ objects = top.evaluate(:scope => scope)
}
end
@@ -176,7 +176,7 @@ class TestAST < Test::Unit::TestCase
scope.type = "nodetest"
scope.keyword = "nodetest"
scope.top = true
- top.evaluate(scope)
+ top.evaluate(:scope => scope)
}
# Verify that, well, nothing really happened, and especially verify
@@ -191,7 +191,7 @@ class TestAST < Test::Unit::TestCase
# And verify that we can evaluate it okay
objects = nil
assert_nothing_raised("Could not retrieve node definition") {
- objects = scope.evalnode([nodename], {})
+ objects = scope.evalnode(:name => [nodename], :facts => {})
}
assert(objects, "Could not retrieve node definition")
@@ -212,7 +212,7 @@ class TestAST < Test::Unit::TestCase
# Verify that we can evaluate the node twice
assert_nothing_raised("Could not retrieve node definition") {
- scope.evalnode([nodename], {})
+ scope.evalnode(:name => [nodename], :facts => {})
}
end
@@ -241,19 +241,23 @@ class TestAST < Test::Unit::TestCase
scope = nil
assert_nothing_raised("Could not evaluate node") {
scope = Puppet::Parser::Scope.new()
- top.evaluate(scope)
+ top.evaluate(:scope => scope)
}
# Verify we can find the node via a search list
objects = nil
assert_nothing_raised("Could not retrieve short node definition") {
- objects = scope.evalnode(["%s.domain.com" % shortname, shortname], {})
+ objects = scope.evalnode(
+ :name => ["%s.domain.com" % shortname, shortname], :facts => {}
+ )
}
assert(objects, "Could not retrieve short node definition")
# and then look for the long name
assert_nothing_raised("Could not retrieve long node definition") {
- objects = scope.evalnode([longname.sub(/\..+/, ''), longname], {})
+ objects = scope.evalnode(
+ :name => [longname.sub(/\..+/, ''), longname], :facts => {}
+ )
}
assert(objects, "Could not retrieve long node definition")
end
@@ -281,13 +285,13 @@ class TestAST < Test::Unit::TestCase
scope = nil
assert_nothing_raised("Could not evaluate node") {
scope = Puppet::Parser::Scope.new()
- top.evaluate(scope)
+ top.evaluate(:scope => scope)
}
# Verify we can find the node via a search list
objects = nil
assert_nothing_raised("Could not retrieve short node definition") {
- objects = scope.evalnode([name], {})
+ objects = scope.evalnode(:name => [name], :facts => {})
}
assert(objects, "Could not retrieve short node definition")
@@ -327,7 +331,7 @@ class TestAST < Test::Unit::TestCase
scope = nil
assert_nothing_raised("Could not evaluate node") {
scope = Puppet::Parser::Scope.new()
- top.evaluate(scope)
+ top.evaluate(:scope => scope)
}
# Verify we can find the node via a search list
@@ -379,13 +383,13 @@ class TestAST < Test::Unit::TestCase
scope = nil
assert_nothing_raised("Could not evaluate node") {
scope = Puppet::Parser::Scope.new()
- top.evaluate(scope)
+ top.evaluate(:scope => scope)
}
# Verify we can find the node via a search list
objects = nil
assert_nothing_raised("Could not retrieve node definition") {
- objects = scope.evalnode([name], {})
+ objects = scope.evalnode(:name => [name], :facts => {})
}
assert(objects, "Could not retrieve node definition")
@@ -455,7 +459,7 @@ class TestAST < Test::Unit::TestCase
scope = nil
assert_nothing_raised("Could not evaluate") {
scope = Puppet::Parser::Scope.new()
- objects = top.evaluate(scope)
+ objects = top.evaluate(:scope => scope)
}
end
@@ -513,7 +517,7 @@ class TestAST < Test::Unit::TestCase
scope = nil
assert_nothing_raised("Could not evaluate") {
scope = Puppet::Parser::Scope.new()
- objects = top.evaluate(scope)
+ objects = top.evaluate(:scope => scope)
}
end
end
diff --git a/test/language/scope.rb b/test/language/scope.rb
index 20c07d742..b4a546267 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -42,7 +42,7 @@ class TestScope < Test::Unit::TestCase
10.times { |index|
# slap some recursion in there
- scope = Puppet::Parser::Scope.new(scope)
+ scope = Puppet::Parser::Scope.new(:parent => scope)
scopes.push scope
var = "var%s" % index
@@ -102,8 +102,8 @@ class TestScope < Test::Unit::TestCase
def test_declarative
# set to declarative
- top = Puppet::Parser::Scope.new(nil,true)
- sub = Puppet::Parser::Scope.new(top)
+ top = Puppet::Parser::Scope.new(:declarative => true)
+ sub = Puppet::Parser::Scope.new(:parent => top)
assert_nothing_raised {
top.setvar("test","value")
@@ -121,8 +121,8 @@ class TestScope < Test::Unit::TestCase
def test_notdeclarative
# set to not declarative
- top = Puppet::Parser::Scope.new(nil,false)
- sub = Puppet::Parser::Scope.new(top)
+ top = Puppet::Parser::Scope.new(:declarative => false)
+ sub = Puppet::Parser::Scope.new(:parent => top)
assert_nothing_raised {
top.setvar("test","value")
@@ -160,7 +160,7 @@ class TestScope < Test::Unit::TestCase
types = %w{a set of types that could be used to set defaults}
10.times { |index|
- scope = Puppet::Parser::Scope.new(scope)
+ scope = Puppet::Parser::Scope.new(:parent => scope)
scopes.push scope
tmptypes = []
@@ -237,7 +237,7 @@ class TestScope < Test::Unit::TestCase
end
def test_strinterp
- scope = Puppet::Parser::Scope.new(nil)
+ scope = Puppet::Parser::Scope.new()
assert_nothing_raised {
scope.setvar("test","value")
@@ -261,18 +261,18 @@ class TestScope < Test::Unit::TestCase
# Test some of the host manipulations
def test_hostlookup
- top = Puppet::Parser::Scope.new(nil)
+ top = Puppet::Parser::Scope.new()
# Create a deep scope tree, so that we know we're doing a deeply recursive
# search.
- mid1 = Puppet::Parser::Scope.new(top)
- mid2 = Puppet::Parser::Scope.new(mid1)
- mid3 = Puppet::Parser::Scope.new(mid2)
- child1 = Puppet::Parser::Scope.new(mid3)
- mida = Puppet::Parser::Scope.new(top)
- midb = Puppet::Parser::Scope.new(mida)
- midc = Puppet::Parser::Scope.new(midb)
- child2 = Puppet::Parser::Scope.new(midc)
+ mid1 = Puppet::Parser::Scope.new(:parent => top)
+ mid2 = Puppet::Parser::Scope.new(:parent => mid1)
+ mid3 = Puppet::Parser::Scope.new(:parent => mid2)
+ child1 = Puppet::Parser::Scope.new(:parent => mid3)
+ mida = Puppet::Parser::Scope.new(:parent => top)
+ midb = Puppet::Parser::Scope.new(:parent => mida)
+ midc = Puppet::Parser::Scope.new(:parent => midb)
+ child2 = Puppet::Parser::Scope.new(:parent => midc)
# verify we can set a host
assert_nothing_raised("Could not create host") {
@@ -352,7 +352,7 @@ class TestScope < Test::Unit::TestCase
# in some pukey-pukeyness.
assert_raise(Puppet::ParseError) {
scope = Puppet::Parser::Scope.new()
- objects = scope.evaluate(top)
+ objects = scope.evaluate(:ast => top)
}
end
@@ -398,7 +398,7 @@ class TestScope < Test::Unit::TestCase
scope = Puppet::Parser::Scope.new()
scope.name = "topscope"
scope.type = "topscope"
- objects = scope.evaluate(top)
+ objects = scope.evaluate(:ast => top)
}
assert_equal(1, objects.length, "Returned too many objects: %s" %
diff --git a/test/parser/parser.rb b/test/parser/parser.rb
index ab8366ba8..e29057e06 100644
--- a/test/parser/parser.rb
+++ b/test/parser/parser.rb
@@ -42,7 +42,8 @@ class TestParser < Test::Unit::TestCase
Puppet.debug("parsing failer %s" % file) if __FILE__ == $0
assert_raise(Puppet::ParseError) {
@parser.file = file
- @parser.parse
+ ast = @parser.parse
+ Puppet::Parser::Scope.new.evaluate(:ast => ast)
}
Puppet::Type.allclear
}
@@ -168,7 +169,7 @@ class TestParser < Test::Unit::TestCase
scope = Puppet::Parser::Scope.new()
scope.name = "parsetest"
scope.type = "parsetest"
- objects = scope.evaluate(ast)
+ objects = scope.evaluate(:ast => ast)
}
method = nil
diff --git a/test/puppettest.rb b/test/puppettest.rb
index 01e7a2f46..dc1f94def 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -703,7 +703,7 @@ module ParserTesting
def classobj(name, args = {})
unless args.include?(:name)
- args[:name] = nameobj(name)
+ args[:type] = nameobj(name)
end
unless args.include?(:code)
args[:code] = AST::ASTArray.new(
@@ -723,7 +723,7 @@ module ParserTesting
def compobj(name, args = {})
args[:file] ||= tempfile()
args[:line] ||= rand(100)
- args[:name] ||= nameobj(name)
+ args[:type] ||= nameobj(name)
args[:code] ||= AST::ASTArray.new(
:file => tempfile(),
:line => rand(100),
diff --git a/test/tagging/tagging.rb b/test/tagging/tagging.rb
index 2cd1e18b3..ed3bd9fbb 100644
--- a/test/tagging/tagging.rb
+++ b/test/tagging/tagging.rb
@@ -54,11 +54,11 @@ class TestTagging < Test::Unit::TestCase
assert_nothing_raised {
scope.setobject(
- "file",
- "/etc/passwd",
- {"owner" => "root"},
- "/yay",
- 1
+ :type => "file",
+ :name => "/etc/passwd",
+ :arguments => {"owner" => "root"},
+ :file => "/yay",
+ :line => 1
)
}
diff --git a/test/test b/test/test
index f1ec37723..9b3613599 100755
--- a/test/test
+++ b/test/test
@@ -4,6 +4,9 @@
# run any or all test suites
basedir = File.dirname(__FILE__)
+if basedir == "."
+ basedir = Dir.getwd
+end
$puppetbase = File.expand_path(File.join(basedir, ".."))
$:.unshift basedir
diff --git a/test/types/query.rb b/test/types/query.rb
index f535686cb..451291cac 100644
--- a/test/types/query.rb
+++ b/test/types/query.rb
@@ -1,7 +1,7 @@
if __FILE__ == $0
$:.unshift '..'
$:.unshift '../../lib'
- $puppetbase = "../.."
+ $puppetbase = File.join(Dir.getwd(), "../..")
end
require 'puppet'
@@ -37,7 +37,7 @@ class TestQuery < Test::Unit::TestCase
:type => "init",
:path => File.join($puppetbase,"examples/root/etc/init.d"),
:hasstatus => true,
- :check => [:running]
+ :check => [:ensure]
)
end
@sleeper = Puppet.type(:service)["sleeper"]