[ruby-core:17126] remove ObjectSpace.each_object from test/unit

2 views
Skip to first unread message

Tanaka Akira

unread,
Jun 6, 2008, 1:37:44 AM6/6/08
to ruby...@ruby-lang.org
I wrote a patch to remove ObjectSpace.each_object from test/unit.

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

Berger, Daniel

unread,
Jun 6, 2008, 10:06:08 AM6/6/08
to ruby...@ruby-lang.org
> -----Original Message-----
> From: Tanaka Akira [mailto:a...@fsij.org]
> Sent: Thursday, June 05, 2008 11:38 PM
> To: ruby...@ruby-lang.org
> Subject: [ruby-core:17126] remove ObjectSpace.each_object
> from test/unit
>
> I wrote a patch to remove ObjectSpace.each_object from test/unit.

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.

Nathan Weizenbaum

unread,
Jun 6, 2008, 12:17:51 PM6/6/08
to ruby...@ruby-lang.org
Berger, Daniel wrote:
>> -----Original Message-----
>> From: Tanaka Akira [mailto:a...@fsij.org]
>> Sent: Thursday, June 05, 2008 11:38 PM
>> To: ruby...@ruby-lang.org
>> Subject: [ruby-core:17126] remove ObjectSpace.each_object
>> from test/unit
>>
>> I wrote a patch to remove ObjectSpace.each_object from test/unit.
>>
>
> Why?
>
I assume because using ObjectSpace imposes a significant performance
penalty in JRuby (and maybe other alternate implementations as well).

Yukihiro Matsumoto

unread,
Jun 6, 2008, 12:20:43 PM6/6/08
to ruby...@ruby-lang.org
Hi,

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.


Kurt Stephens

unread,
Jun 7, 2008, 5:16:43 AM6/7/08
to ruby...@ruby-lang.org
Yukihiro Matsumoto wrote:
> Hi,
>
> 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.
> |

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/

Tanaka Akira

unread,
Jun 7, 2008, 5:27:37 AM6/7/08
to ruby...@ruby-lang.org
In article <484A52...@kurtstephens.com>,
Kurt Stephens <k...@kurtstephens.com> writes:

> 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

Reply all
Reply to author
Forward
0 new messages