diff options
Diffstat (limited to 'lib/test')
-rw-r--r-- | lib/test/unit/autorunner.rb | 5 | ||||
-rw-r--r-- | lib/test/unit/collector/dir.rb | 12 | ||||
-rw-r--r-- | lib/test/unit/collector/objectspace.rb | 14 | ||||
-rw-r--r-- | lib/test/unit/testcase.rb | 5 |
4 files changed, 25 insertions, 11 deletions
diff --git a/lib/test/unit/autorunner.rb b/lib/test/unit/autorunner.rb index 861b50e00f..c252e2e7cb 100644 --- a/lib/test/unit/autorunner.rb +++ b/lib/test/unit/autorunner.rb @@ -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 = { diff --git a/lib/test/unit/collector/dir.rb b/lib/test/unit/collector/dir.rb index 154c402a25..9c311b72ce 100644 --- a/lib/test/unit/collector/dir.rb +++ b/lib/test/unit/collector/dir.rb @@ -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,8 +43,14 @@ module Test def find_test_cases(ignore=[]) cases = [] - @object_space.each_object(Class) do |c| - cases << c if(c < TestCase && !ignore.include?(c)) + 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 diff --git a/lib/test/unit/collector/objectspace.rb b/lib/test/unit/collector/objectspace.rb index a0f837e33e..a6136e37bf 100644 --- a/lib/test/unit/collector/objectspace.rb +++ b/lib/test/unit/collector/objectspace.rb @@ -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,8 +20,14 @@ module Test def collect(name=NAME) suite = TestSuite.new(name) sub_suites = [] - @source.each_object(Class) do |klass| - if(Test::Unit::TestCase > klass) + 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 diff --git a/lib/test/unit/testcase.rb b/lib/test/unit/testcase.rb index 27bd79255d..3cf80d2256 100644 --- a/lib/test/unit/testcase.rb +++ b/lib/test/unit/testcase.rb @@ -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) |