summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-01 05:57:25 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-01 05:57:25 +0000
commit69a07b1d856efaba9bba8c9cccc8a4f11efcbfdd (patch)
tree470feb3593ed52b0a6edb03195b0e96986444794 /test
parent42d15feb3c74e1cae6c70dcd3ea895796f0a8e7b (diff)
downloadpuppet-69a07b1d856efaba9bba8c9cccc8a4f11efcbfdd.tar.gz
puppet-69a07b1d856efaba9bba8c9cccc8a4f11efcbfdd.tar.xz
puppet-69a07b1d856efaba9bba8c9cccc8a4f11efcbfdd.zip
The resolve functionality in "test" is almost working...
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2149 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/lib/puppettest.rb13
-rw-r--r--test/lib/rake/puppet_test_loader.rb2
-rwxr-xr-xtest/test144
3 files changed, 118 insertions, 41 deletions
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index cda91e77b..2354722a9 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -17,17 +17,6 @@ module PuppetTest
def self.munge_argv
require 'getoptlong'
- def resolve(dir, method)
- end
-
- def ruby_files(dir)
- files = []
- # First collect the entire file list.
- find(dir) { |f| files << f if f =~ /\.rb$/ }
- files
- end
-
- #[ "--size", "-s", GetoptLong::REQUIRED_ARGUMENT ],
result = GetoptLong.new(
[ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
[ "--resolve", "-r", GetoptLong::REQUIRED_ARGUMENT ],
@@ -35,7 +24,7 @@ module PuppetTest
[ "--help", "-h", GetoptLong::NO_ARGUMENT ]
)
- usage = "USAGE: %s [--help] <testsuite> <testsuite> .." % $0
+ usage = "USAGE: TESTOPTS='[-n <method> -n <method> ...] [-d]' rake [target] [target] ..."
opts = []
diff --git a/test/lib/rake/puppet_test_loader.rb b/test/lib/rake/puppet_test_loader.rb
index 83531c677..a85cc8e6b 100644
--- a/test/lib/rake/puppet_test_loader.rb
+++ b/test/lib/rake/puppet_test_loader.rb
@@ -5,8 +5,6 @@ require 'puppettest'
args = PuppetTest.munge_argv
-p $puppet_debug
-
args.each { |f| require f unless f =~ /^-/ }
runner = Test::Unit::AutoRunner.new(false)
diff --git a/test/test b/test/test
index c9c92d33d..586f4957a 100755
--- a/test/test
+++ b/test/test
@@ -6,51 +6,143 @@
# easily.
require 'find'
+require 'getoptlong'
include Find
-basedir = File.dirname(__FILE__)
-$:.unshift(File.join(basedir, "lib"))
+result = GetoptLong.new(
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+)
-require 'puppettest'
+usage = "USAGE: %s [--help] suite method" % $0
+
+$options = {}
+
+result.each { |opt,arg|
+ case opt
+ when "--verbose"
+ $options[:verbose] = true
+ when "--debug"
+ $options[:debug] = true
+ when "--help"
+ puts usage
+ exit
+ else
+ raise "no such option %s" % opt
+ end
+}
+
+def dirs
+ Dir.glob("*").find_all { |d| FileTest.directory?(d) }.reject { |d|
+ ["lib", "data"].include?(d)
+ }
+end
+
+def rake(*args)
+ print "trying %s..." % args.join(" ")
+ output = %x{rake %s} % args.join(" ")
+
+ if $?.exitstatus == 0
+ puts "succeeded"
+ return true
+ else
+ puts "failed"
+ return false
+ end
+end
def resolve(dir, method)
+ dirs = dirs()
+
+ failed = nil
+ dirs.each do |d|
+ next if d == dir
+ unless run(d, dir)
+ failed = d
+ break
+ end
+ end
+ puts "%s failed" % failed
+
+ files = ruby_files(failed)
+
+ files.each do |file|
+ unless run(file, dir)
+ puts file
+ exit(0)
+ end
+ end
+
+ exit(1)
end
def ruby_files(dir)
files = []
# First collect the entire file list.
- find(dir) { |f| files << f if f =~ /\.rb$/ }
+ begin
+ find(dir) { |f| files << f if f =~ /\.rb$/ }
+ rescue => detail
+ puts "could not find on %s: %s" % [dir.inspect, detail]
+ end
files
end
-suites = nil
-args = PuppetTest.munge_argv
+def run(*files)
+ args = %w{ruby}
+ args << "-Ilib:../lib"
+ args += ARGV
+ args << "lib/rake/puppet_test_loader.rb"
-unless args.length != 0
- Dir.glob("*").find_all { |d| FileTest.directory?(d) }.reject { |d|
- d == "lib"
- }.each do |d|
- args << d
+ print files.join(" ") + "... "
+ $stdout.flush
+
+ files.each do |file|
+ case File.stat(file).ftype
+ when "file": args << file
+ when "directory": args += ruby_files(file)
+ else
+ $stderr.puts "Skipping %s; can't handle %s" %
+ [file, File.stat(file).ftype]
+ end
+ end
+ args = args.join(" ")
+ if $options[:verbose]
+ p args
+ end
+ output = %x{#{args} 2>&1}
+ if $options[:debug]
+ print output
end
-end
+ if $?.exitstatus == 0
+ puts "succeeded"
+ return true
+ else
+ puts "failed"
+ puts output
+ return false
+ end
+end
-exit
-files = []
+dir = ARGV.shift
+method = ARGV.shift
-args.each do |test|
- if FileTest.directory?(test)
- files += ruby_files(test)
- end
+unless dir and method
+ $stderr.puts usage
+ exit(1)
end
-args = %w{ruby}
-args << "-Ilib:../lib"
-args += ARGV
-args << "lib/rake/puppet_test_loader.rb"
-args += files
-p args
-system(*files)
+resolve(dir, method)
+#
+#
+#files = []
+#
+#args.each do |test|
+# if FileTest.directory?(test)
+# files += ruby_files(test)
+# end
+#end
## Now load all of our files.
#files.each do |file|
@@ -60,5 +152,3 @@ system(*files)
#runner = Test::Unit::AutoRunner.new(false)
#runner.process_args
#runner.run
-
-# $Id$