mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/test/unit/testcase.rb: collect decendants of
Test::Unit::TestCase using inherited. * lib/test/unit/autorunner.rb: don't use ObjectSpace.each_object. * lib/test/unit/collector/dir.rb: ditto. * lib/test/unit/collector/objectspace.rb: ditto. [ruby-core:17126] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
28b216ac45
commit
7d166d26a5
5 changed files with 38 additions and 11 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Fri Jul 4 22:15:29 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* lib/test/unit/testcase.rb: collect decendants of
|
||||
Test::Unit::TestCase using inherited.
|
||||
|
||||
* lib/test/unit/autorunner.rb: don't use ObjectSpace.each_object.
|
||||
|
||||
* lib/test/unit/collector/dir.rb: ditto.
|
||||
|
||||
* lib/test/unit/collector/objectspace.rb: ditto.
|
||||
|
||||
[ruby-core:17126]
|
||||
|
||||
Fri Jul 4 20:43:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* include/ruby/oniguruma.h (OnigEncoding): removed auxiliary_data.
|
||||
|
|
|
@ -14,10 +14,7 @@ module Test
|
|||
|
||||
def self.standalone?
|
||||
return false unless("-e" == $0)
|
||||
ObjectSpace.each_object(Class) do |klass|
|
||||
return false if(klass < TestCase)
|
||||
end
|
||||
true
|
||||
TestCase::DECENDANT_CLASSES.empty?
|
||||
end
|
||||
|
||||
RUNNERS = {
|
||||
|
|
|
@ -10,7 +10,7 @@ module Test
|
|||
attr_reader :pattern, :exclude
|
||||
attr_accessor :base
|
||||
|
||||
def initialize(dir=::Dir, file=::File, object_space=::ObjectSpace, req=nil)
|
||||
def initialize(dir=::Dir, file=::File, object_space=nil, req=nil)
|
||||
super()
|
||||
@dir = dir
|
||||
@file = file
|
||||
|
@ -43,9 +43,15 @@ module Test
|
|||
|
||||
def find_test_cases(ignore=[])
|
||||
cases = []
|
||||
if @object_space
|
||||
@object_space.each_object(Class) do |c|
|
||||
cases << c if(c < TestCase && !ignore.include?(c))
|
||||
end
|
||||
else
|
||||
TestCase::DECENDANT_CLASSES.each do |c|
|
||||
cases << c if !ignore.include?(c)
|
||||
end
|
||||
end
|
||||
ignore.concat(cases)
|
||||
cases
|
||||
end
|
||||
|
|
|
@ -10,9 +10,9 @@ module Test
|
|||
class ObjectSpace
|
||||
include Test::Unit::Collector
|
||||
|
||||
NAME = 'collected from the ObjectSpace'
|
||||
NAME = 'collected from the subclasses of TestSuite'
|
||||
|
||||
def initialize(source=::ObjectSpace)
|
||||
def initialize(source=nil)
|
||||
super()
|
||||
@source = source
|
||||
end
|
||||
|
@ -20,11 +20,17 @@ module Test
|
|||
def collect(name=NAME)
|
||||
suite = TestSuite.new(name)
|
||||
sub_suites = []
|
||||
if @source
|
||||
@source.each_object(Class) do |klass|
|
||||
if(Test::Unit::TestCase > klass)
|
||||
add_suite(sub_suites, klass.suite)
|
||||
end
|
||||
end
|
||||
else
|
||||
TestCase::DECENDANT_CLASSES.each do |klass|
|
||||
add_suite(sub_suites, klass.suite)
|
||||
end
|
||||
end
|
||||
sort(sub_suites).each{|s| suite << s}
|
||||
suite
|
||||
end
|
||||
|
|
|
@ -34,6 +34,11 @@ module Test
|
|||
PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, Interrupt,
|
||||
SystemExit]
|
||||
|
||||
DECENDANT_CLASSES = []
|
||||
def self.inherited(decendant)
|
||||
DECENDANT_CLASSES << decendant
|
||||
end
|
||||
|
||||
# Creates a new instance of the fixture for running the
|
||||
# test represented by test_method_name.
|
||||
def initialize(test_method_name)
|
||||
|
|
Loading…
Add table
Reference in a new issue