diff options
author | Luke Kanies <luke@madstop.com> | 2005-04-13 21:42:15 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-04-13 21:42:15 +0000 |
commit | 67b7b3491f1e5a9cc8904ec1193a070dce641e76 (patch) | |
tree | 003402284bfba91aceec3165d2ae16964ac0a8b1 | |
parent | 35f742cd79a68778c7c9d9ebc4a31d4f98201d1c (diff) | |
download | puppet-67b7b3491f1e5a9cc8904ec1193a070dce641e76.tar.gz puppet-67b7b3491f1e5a9cc8904ec1193a070dce641e76.tar.xz puppet-67b7b3491f1e5a9cc8904ec1193a070dce641e76.zip |
okay, all tests pass again
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@133 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | test/blinktest.rb | 38 | ||||
-rw-r--r-- | test/client/tc_client.rb | 6 | ||||
-rw-r--r-- | test/objects/tc_basic.rb | 17 | ||||
-rw-r--r-- | test/objects/tc_file.rb | 8 | ||||
-rw-r--r-- | test/objects/tc_package.rb | 6 | ||||
-rw-r--r-- | test/objects/tc_service.rb | 8 | ||||
-rw-r--r-- | test/objects/tc_symlink.rb | 8 | ||||
-rw-r--r-- | test/other/tc_function.rb | 6 | ||||
-rw-r--r-- | test/other/tc_oparse.rb | 6 | ||||
-rw-r--r-- | test/other/tc_selector.rb | 6 | ||||
-rwxr-xr-x | test/test | 45 | ||||
-rw-r--r-- | test/ts_objects.rb | 6 | ||||
-rw-r--r-- | test/ts_other.rb | 6 |
13 files changed, 123 insertions, 43 deletions
diff --git a/test/blinktest.rb b/test/blinktest.rb index 4596eaaf7..d84091be5 100644 --- a/test/blinktest.rb +++ b/test/blinktest.rb @@ -1,23 +1,37 @@ # $Id$ -unless defined? TestSuite +unless defined? BlinkTestSuite $VERBOSE = true $:.unshift File.join(Dir.getwd, '../lib') - class TestSuite + class BlinkTestSuite attr_accessor :subdir - def initialize(files) - files.collect { |file| - if file =~ /\.rb/ - file - else - "tc_" + file + ".rb" - end + def BlinkTestSuite.list + Dir.entries(".").find_all { |file| + FileTest.directory?(file) and file !~ /^\./ + } + end + + def initialize(name) + unless FileTest.directory?(name) + puts "TestSuites are directories containing test cases" + puts "no such directory: %s" % name + exit(65) + end + + # load each of the files + Dir.entries(name).collect { |file| + File.join(name,file) + }.find_all { |file| + FileTest.file?(file) and file =~ /tc_.+\.rb$/ }.sort { |a,b| - File.stat(a) <=> File.stat(b) + # in the order they were modified, so the last modified files + # are loaded and thus displayed last + File.stat(b) <=> File.stat(a) }.each { |file| + puts "requiring %s" % file require file } end @@ -37,7 +51,3 @@ unless defined? TestSuite } end end - -if __FILE__ == $0 # if we're executing the top-level library... - TestSuite.new(Dir.glob("ts_*")) -end diff --git a/test/client/tc_client.rb b/test/client/tc_client.rb index 53f2b940b..e7cbd6ef9 100644 --- a/test/client/tc_client.rb +++ b/test/client/tc_client.rb @@ -1,4 +1,8 @@ -$:.unshift '../lib' if __FILE__ == $0 # Make this library first! +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $blinkbase = "../.." +end require 'blink' require 'blink/client' diff --git a/test/objects/tc_basic.rb b/test/objects/tc_basic.rb index f7ffbebfa..75cec7b7b 100644 --- a/test/objects/tc_basic.rb +++ b/test/objects/tc_basic.rb @@ -1,4 +1,8 @@ -$:.unshift '../lib' if __FILE__ == $0 # Make this library first! +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $blinkbase = "../.." +end require 'blink' require 'test/unit' @@ -26,12 +30,13 @@ class TestBasic < Test::Unit::TestCase } assert_nothing_raised() { - unless Blink::Objects::File.has_key?("../examples/root/etc/configfile") + cfile = File.join($blinkbase,"examples/root/etc/configfile") + unless Blink::Objects::File.has_key?(cfile) Blink::Objects::File.new( - :path => "../examples/root/etc/configfile" + :path => cfile ) end - @configfile = Blink::Objects::File["../examples/root/etc/configfile"] + @configfile = Blink::Objects::File[cfile] } assert_nothing_raised() { unless Blink::Objects::Service.has_key?("sleeper") @@ -40,7 +45,7 @@ class TestBasic < Test::Unit::TestCase :running => 1 ) Blink::Objects::Service.addpath( - File.expand_path("../examples/root/etc/init.d") + File.join($blinkbase,"examples/root/etc/init.d") ) end @sleeper = Blink::Objects::Service["sleeper"] @@ -72,7 +77,7 @@ class TestBasic < Test::Unit::TestCase ) assert_equal( - "../examples/root/etc/configfile", + File.join($blinkbase,"examples/root/etc/configfile"), @configfile.name ) diff --git a/test/objects/tc_file.rb b/test/objects/tc_file.rb index 97a5d8591..b92f20d04 100644 --- a/test/objects/tc_file.rb +++ b/test/objects/tc_file.rb @@ -1,4 +1,8 @@ -$:.unshift '../lib' if __FILE__ == $0 # Make this library first! +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $blinkbase = "../.." +end require 'blink' require 'test/unit' @@ -11,7 +15,7 @@ class TestFile < Test::Unit::TestCase # objects in a central store def setup @file = nil - @path = "../examples/root/etc/configfile" + @path = File.join($blinkbase,"examples/root/etc/configfile") Blink[:debug] = 1 assert_nothing_raised() { unless Blink::Objects::File.has_key?(@path) diff --git a/test/objects/tc_package.rb b/test/objects/tc_package.rb index e9a8bb30e..38ea28e31 100644 --- a/test/objects/tc_package.rb +++ b/test/objects/tc_package.rb @@ -1,4 +1,8 @@ -$:.unshift '../lib' if __FILE__ == $0 # Make this library first! +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $blinkbase = "../.." +end require 'blink/objects/package' require 'test/unit' diff --git a/test/objects/tc_service.rb b/test/objects/tc_service.rb index 4967f3a01..36788eae4 100644 --- a/test/objects/tc_service.rb +++ b/test/objects/tc_service.rb @@ -1,4 +1,8 @@ -$:.unshift '../lib' if __FILE__ == $0 # Make this library first! +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $blinkbase = "../.." +end require 'blink' require 'test/unit' @@ -20,7 +24,7 @@ class TestService < Test::Unit::TestCase :running => 1 ) Blink::Objects::Service.addpath( - File.expand_path("../examples/root/etc/init.d") + File.join($blinkbase,"examples/root/etc/init.d") ) end @sleeper = Blink::Objects::Service["sleeper"] diff --git a/test/objects/tc_symlink.rb b/test/objects/tc_symlink.rb index 4dd2bd864..a75812ff3 100644 --- a/test/objects/tc_symlink.rb +++ b/test/objects/tc_symlink.rb @@ -1,4 +1,8 @@ -$:.unshift '../lib' if __FILE__ == $0 # Make this library first! +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $blinkbase = "../.." +end require 'blink' require 'test/unit' @@ -11,7 +15,7 @@ class TestSymlink < Test::Unit::TestCase # objects in a central store def setup @symlink = nil - @path = "../examples/root/etc/symlink" + @path = File.join($blinkbase,"examples/root/etc/symlink") Kernel.system("rm -f %s" % @path) Blink[:debug] = 1 diff --git a/test/other/tc_function.rb b/test/other/tc_function.rb index 0fda38a5d..998fac7ae 100644 --- a/test/other/tc_function.rb +++ b/test/other/tc_function.rb @@ -1,4 +1,8 @@ -$:.unshift '../lib' if __FILE__ == $0 # Make this library first! +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $blinkbase = "../.." +end require 'blink/function' require 'blink/fact' diff --git a/test/other/tc_oparse.rb b/test/other/tc_oparse.rb index e737863b2..fbf64a85e 100644 --- a/test/other/tc_oparse.rb +++ b/test/other/tc_oparse.rb @@ -1,4 +1,8 @@ -$:.unshift '../lib' if __FILE__ == $0 # Make this library first! +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $blinkbase = "../.." +end require 'blink' require 'blink/oparse' diff --git a/test/other/tc_selector.rb b/test/other/tc_selector.rb index 97d02859f..26cf6165e 100644 --- a/test/other/tc_selector.rb +++ b/test/other/tc_selector.rb @@ -1,4 +1,8 @@ -$:.unshift '../lib' if __FILE__ == $0 # Make this library first! +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $blinkbase = "../.." +end require 'blink/selector' require 'test/unit' diff --git a/test/test b/test/test new file mode 100755 index 000000000..2fad8dd5f --- /dev/null +++ b/test/test @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby + +#------------------------------------------------------------ +# $Id$ +# +# run any or all test suites + +$:.unshift '.' +$:.unshift '../lib' + +require 'blinktest.rb' + + +require 'getoptlong' + + #[ "--size", "-s", GetoptLong::REQUIRED_ARGUMENT ], +result = GetoptLong.new( + [ "--help", "-h", GetoptLong::NO_ARGUMENT ] +) + +usage = "USAGE: %s [--help] <testsuite> <testsuite> .." % $0 + +result.each { |opt,arg| + case opt + when "--help" + puts usage + exit + else + raise "Invalid option '#{opt}'" + end +} + +$blinkbase = ".." + +suites = nil + +if ARGV.length != 0 + suites = ARGV +else + suites = BlinkTestSuite.list +end + +suites.each { |suite| + BlinkTestSuite.new(suite) +} diff --git a/test/ts_objects.rb b/test/ts_objects.rb deleted file mode 100644 index 3cada1731..000000000 --- a/test/ts_objects.rb +++ /dev/null @@ -1,6 +0,0 @@ -# $Id$ - -require "blinktest.rb" - -TestSuite.new(%w{basic file symlink service package}) - diff --git a/test/ts_other.rb b/test/ts_other.rb deleted file mode 100644 index 5ad567a4b..000000000 --- a/test/ts_other.rb +++ /dev/null @@ -1,6 +0,0 @@ -# $Id$ - -require "blinktest.rb" - -TestSuite.new(%w{oparse selector function}) - |