How about this?
Index: lib/test/unit/autorunner.rb
===================================================================
--- lib/test/unit/autorunner.rb (revision 16852)
+++ lib/test/unit/autorunner.rb (working copy)
@@ -14,8 +14,8 @@ module Test
def self.standalone?
return false unless("-e" == $0)
- ObjectSpace.each_object(Class) do |klass|
- return false if(klass < TestCase)
+ TestCase::DECENDANT_CLASSES.each do |klass|
+ return false
end
true
end
Index: lib/test/unit/collector/dir.rb
===================================================================
--- lib/test/unit/collector/dir.rb (revision 16852)
+++ lib/test/unit/collector/dir.rb (working copy)
@@ -10,11 +10,11 @@ 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
- @object_space = object_space
+ # object_space is ignored.
@req = req
@pattern = []
@exclude = []
@@ -43,8 +43,8 @@ module Test
def find_test_cases(ignore=[])
cases = []
- @object_space.each_object(Class) do |c|
- cases << c if(c < TestCase && !ignore.include?(c))
+ TestCase::DECENDANT_CLASSES.each do |c|
+ cases << c if !ignore.include?(c)
end
ignore.concat(cases)
cases
Index: lib/test/unit/collector/objectspace.rb
===================================================================
--- lib/test/unit/collector/objectspace.rb (revision 16852)
+++ lib/test/unit/collector/objectspace.rb (working copy)
@@ -10,20 +10,17 @@ 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
super()
- @source = source
end
def collect(name=NAME)
suite = TestSuite.new(name)
sub_suites = []
- @source.each_object(Class) do |klass|
- if(Test::Unit::TestCase > klass)
- add_suite(sub_suites, klass.suite)
- end
+ TestCase::DECENDANT_CLASSES.each do |klass|
+ add_suite(sub_suites, klass.suite)
end
sort(sub_suites).each{|s| suite << s}
suite
Index: lib/test/unit/testcase.rb
===================================================================
--- lib/test/unit/testcase.rb (revision 16852)
+++ lib/test/unit/testcase.rb (working copy)
@@ -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)
--
Tanaka Akira
Why?
This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.
In message "Re: [ruby-core:17126] remove ObjectSpace.each_object from test/unit"
on Fri, 6 Jun 2008 14:37:44 +0900, Tanaka Akira <a...@fsij.org> writes:
|I wrote a patch to remove ObjectSpace.each_object from test/unit.
|
|How about this?
Can you commit?
matz.
Can we remove ObjectSpace iteration from Ruby completely? It prevents using other GC
techniques and implementations. An efficient set of weak collections would be
more generic and provide a mechanism for building global collections.
Kurt Stephens
http://kurtstephens.com/
> Can we remove ObjectSpace iteration from Ruby completely? It prevents using other GC
> techniques and implementations. An efficient set of weak collections would be
> more generic and provide a mechanism for building global collections.
What the GC techniques?
--
Tanaka Akira