summaryrefslogtreecommitdiffstats
path: root/test/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-12 15:32:25 -0500
committerLuke Kanies <luke@madstop.com>2007-09-12 15:32:25 -0500
commita6fe70054f4fb3efe4d558ffdd244917ca1c6f9c (patch)
tree6b8dbf7f3f2779254174b0829412a5365ad6ebed /test/lib
parent1459c507ddccff2a2a6fbadd4c880c023b5e9893 (diff)
downloadpuppet-a6fe70054f4fb3efe4d558ffdd244917ca1c6f9c.tar.gz
puppet-a6fe70054f4fb3efe4d558ffdd244917ca1c6f9c.tar.xz
puppet-a6fe70054f4fb3efe4d558ffdd244917ca1c6f9c.zip
Another intermediate commit. The node and fact classes are now functional and are used instead of the network handlers, which have been removed. There are some failing tests as a result, but I want to get this code committed before I massage the rest of the system to make it work again.
Diffstat (limited to 'test/lib')
-rwxr-xr-xtest/lib/puppettest.rb1
-rw-r--r--test/lib/puppettest/parsertesting.rb1
-rw-r--r--test/lib/puppettest/runnable_test.rb30
-rw-r--r--test/lib/puppettest/testcase.rb23
4 files changed, 33 insertions, 22 deletions
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 45c5b2ed9..06b85f147 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -264,6 +264,7 @@ module PuppetTest
Puppet::Type.allclear
Puppet::Util::Storage.clear
Puppet.clear
+ Puppet.config.clear
@memoryatend = Puppet::Util.memory
diff = @memoryatend - @memoryatstart
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb
index eef0cd8bc..c4bd7dc2b 100644
--- a/test/lib/puppettest/parsertesting.rb
+++ b/test/lib/puppettest/parsertesting.rb
@@ -42,7 +42,6 @@ module PuppetTest::ParserTesting
end
def mkcompile(parser = nil)
- require 'puppet/network/handler/node'
parser ||= mkparser
node = mknode
return Compile.new(node, parser)
diff --git a/test/lib/puppettest/runnable_test.rb b/test/lib/puppettest/runnable_test.rb
new file mode 100644
index 000000000..e4b0f9033
--- /dev/null
+++ b/test/lib/puppettest/runnable_test.rb
@@ -0,0 +1,30 @@
+# Manage whether a test is runnable.
+module PuppetTest
+ module RunnableTest
+ # Confine this test based on specified criteria. The keys of the
+ # hash should be the message to use if the test is not suitable,
+ # and the values should be either 'true' or 'false'; true values
+ # mean the test is suitable.
+ def confine(hash)
+ @confines ||= {}
+ hash.each do |message, result|
+ @confines[message] = result
+ end
+ end
+
+ # Evaluate all of our tests to see if any of them are false
+ # and thus whether this test is considered not runnable.
+ def runnable?
+ @messages ||= []
+ return false unless @messages.empty?
+ return true unless defined? @confines
+ @confines.find_all do |message, result|
+ ! result
+ end.each do |message, result|
+ @messages << message
+ end
+
+ return @messages.empty?
+ end
+ end
+end
diff --git a/test/lib/puppettest/testcase.rb b/test/lib/puppettest/testcase.rb
index cfedeee26..15c835854 100644
--- a/test/lib/puppettest/testcase.rb
+++ b/test/lib/puppettest/testcase.rb
@@ -4,28 +4,11 @@
# Copyright (c) 2007. All rights reserved.
require 'puppettest'
+require 'puppettest/runnable_test'
class PuppetTest::TestCase < Test::Unit::TestCase
include PuppetTest
- def self.confine(hash)
- @confines ||= {}
- hash.each do |message, result|
- @confines[message] = result
- end
- end
-
- def self.runnable?
- @messages ||= []
- return false unless @messages.empty?
- return true unless defined? @confines
- @confines.find_all do |message, result|
- ! result
- end.each do |message, result|
- @messages << message
- end
-
- return @messages.empty?
- end
+ extend PuppetTest::RunnableTest
def self.suite
# Always skip this parent class. It'd be nice if there were a
@@ -44,5 +27,3 @@ class PuppetTest::TestCase < Test::Unit::TestCase
end
end
end
-
-# $Id$