diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-04 13:19:24 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-04 13:19:24 +0000 |
commit | 7d166d26a5fbe66cdd7974314104f85dd29977ab (patch) | |
tree | 6cafe43af9d7b0e4aeb591b31cf4ecde6b527f7f | |
parent | 28b216ac45262819f8bc7be0b1417a707974f94b (diff) | |
download | ruby-7d166d26a5fbe66cdd7974314104f85dd29977ab.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 13 | ||||
-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 |
5 files changed, 38 insertions, 11 deletions
@@ -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. 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) |