|
Revision 1541, 1.5 kB
(checked in by nahi, 4 years ago)
|
update unit test runner for ruby-1.6.8
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
author date id revision
|
| Line | |
|---|
| 1 |
require 'test/unit/testsuite' |
|---|
| 2 |
require 'test/unit/testcase' |
|---|
| 3 |
|
|---|
| 4 |
$KCODE = 'UTF8' |
|---|
| 5 |
|
|---|
| 6 |
rcsid = %w$Id$ |
|---|
| 7 |
Version = rcsid[2].scan(/\d+/).collect!(&method(:Integer)).freeze |
|---|
| 8 |
Release = rcsid[3].freeze |
|---|
| 9 |
|
|---|
| 10 |
module Test |
|---|
| 11 |
module Unit |
|---|
| 12 |
module Assertions |
|---|
| 13 |
alias assert_raise assert_raises |
|---|
| 14 |
end |
|---|
| 15 |
end |
|---|
| 16 |
end |
|---|
| 17 |
|
|---|
| 18 |
class BulkTestSuite < Test::Unit::TestSuite |
|---|
| 19 |
def self.suite |
|---|
| 20 |
suite = Test::Unit::TestSuite.new |
|---|
| 21 |
ObjectSpace.each_object(Class) do |klass| |
|---|
| 22 |
suite << klass.suite if (Test::Unit::TestCase > klass) |
|---|
| 23 |
end |
|---|
| 24 |
suite |
|---|
| 25 |
end |
|---|
| 26 |
end |
|---|
| 27 |
|
|---|
| 28 |
runners_map = { |
|---|
| 29 |
'console' => proc do |suite| |
|---|
| 30 |
require 'test/unit/ui/console/testrunner' |
|---|
| 31 |
passed = Test::Unit::UI::Console::TestRunner.run(suite).passed? |
|---|
| 32 |
exit(passed ? 0 : 1) |
|---|
| 33 |
end, |
|---|
| 34 |
'gtk' => proc do |suite| |
|---|
| 35 |
require 'test/unit/ui/gtk/testrunner' |
|---|
| 36 |
Test::Unit::UI::GTK::TestRunner.run(suite) |
|---|
| 37 |
end, |
|---|
| 38 |
'fox' => proc do |suite| |
|---|
| 39 |
require 'test/unit/ui/fox/testrunner' |
|---|
| 40 |
Test::Unit::UI::Fox::TestRunner.run(suite) |
|---|
| 41 |
end, |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
def test_require(list) |
|---|
| 45 |
list.each do |tc_name| |
|---|
| 46 |
if File.directory?(tc_name) |
|---|
| 47 |
newlist = Dir.glob(File.join(tc_name, "**", "test_*.rb")).sort |
|---|
| 48 |
test_require(newlist) |
|---|
| 49 |
else |
|---|
| 50 |
dir = File.expand_path(File.dirname(tc_name)) |
|---|
| 51 |
backup = $:.dup |
|---|
| 52 |
$:.push(dir) |
|---|
| 53 |
require tc_name |
|---|
| 54 |
$:.replace(backup) |
|---|
| 55 |
end |
|---|
| 56 |
end |
|---|
| 57 |
end |
|---|
| 58 |
|
|---|
| 59 |
argv = ARGV |
|---|
| 60 |
if argv.empty? |
|---|
| 61 |
argv = Dir.glob(File.join(File.dirname(__FILE__), "**", "test_*.rb")).sort |
|---|
| 62 |
end |
|---|
| 63 |
|
|---|
| 64 |
test_require(argv) |
|---|
| 65 |
|
|---|
| 66 |
runner = 'console' |
|---|
| 67 |
GC.start |
|---|
| 68 |
runners_map[runner].call(BulkTestSuite.suite) |
|---|