mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
65fe176ea4
* lib/test/unit.rb: Documentation update. * lib/test/unit/ui/console/testrunner.rb (TestRunner#initialize): Ditto. * lib/test/unit.rb: Factored out an ObjectSpace collector. * lib/test/unit/collector/objectspace.rb: Ditto. * sample/testunit/*: Added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
# Author:: Nathaniel Talbott.
|
|
# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
|
# License:: Ruby license.
|
|
|
|
module Test
|
|
module Unit
|
|
module Collector
|
|
class ObjectSpace
|
|
NAME = 'collected from the ObjectSpace'
|
|
|
|
def initialize(source=::ObjectSpace)
|
|
@source = source
|
|
end
|
|
|
|
def collect(name=NAME)
|
|
suite = TestSuite.new(name)
|
|
tests = []
|
|
@source.each_object(Class) do |klass|
|
|
tests.concat(klass.suite.tests) if(Test::Unit::TestCase > klass)
|
|
end
|
|
tests.each{|test| suite << test if(include(test))}
|
|
suite
|
|
end
|
|
|
|
def include(test)
|
|
return true unless(@filters)
|
|
@filters.each do |filter|
|
|
return true if(filter.call(test))
|
|
end
|
|
false
|
|
end
|
|
|
|
def filter=(filters)
|
|
@filters = case(filters)
|
|
when Proc
|
|
[filters]
|
|
when Array
|
|
filters
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|