diff options
author | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-23 21:32:19 +0000 |
---|---|---|
committer | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-23 21:32:19 +0000 |
commit | 62c17944c7a07d9742b05abfddd4593b3ee6eaff (patch) | |
tree | fe2b8ff8e03f91887c065beaa995a4cae09f6347 /lib/test/unit/collector | |
parent | 2e311f6bd56a6f6f380e400863a21adbfb73ddfe (diff) | |
download | ruby-62c17944c7a07d9742b05abfddd4593b3ee6eaff.tar.gz |
Removed test/unit
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/test/unit/collector')
-rw-r--r-- | lib/test/unit/collector/dir.rb | 113 | ||||
-rw-r--r-- | lib/test/unit/collector/objectspace.rb | 40 |
2 files changed, 0 insertions, 153 deletions
diff --git a/lib/test/unit/collector/dir.rb b/lib/test/unit/collector/dir.rb deleted file mode 100644 index 9c311b72ce..0000000000 --- a/lib/test/unit/collector/dir.rb +++ /dev/null @@ -1,113 +0,0 @@ -require 'test/unit/testsuite' -require 'test/unit/collector' - -module Test - module Unit - module Collector - class Dir - include Collector - - attr_reader :pattern, :exclude - attr_accessor :base - - def initialize(dir=::Dir, file=::File, object_space=nil, req=nil) - super() - @dir = dir - @file = file - @object_space = object_space - @req = req - @pattern = [/\btest_.*\.rb\Z/m] - @exclude = [] - end - - def collect(*from) - basedir = @base - $:.push(basedir) if basedir - if(from.empty?) - recursive_collect('.', find_test_cases) - elsif(from.size == 1) - recursive_collect(from.first, find_test_cases) - else - suites = [] - from.each do |f| - suite = recursive_collect(f, find_test_cases) - suites << suite unless(suite.tests.empty?) - end - suite = TestSuite.new("[#{from.join(', ')}]") - sort(suites).each{|s| suite << s} - suite - end - ensure - $:.delete_at($:.rindex(basedir)) if basedir - end - - def find_test_cases(ignore=[]) - cases = [] - 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 - end - - def recursive_collect(name, already_gathered) - sub_suites = [] - path = realdir(name) - if @file.directory?(path) - dir_name = name unless name == '.' - @dir.entries(path).each do |e| - next if(e == '.' || e == '..') - e_name = dir_name ? @file.join(dir_name, e) : e - if @file.directory?(realdir(e_name)) - next if /\A(?:CVS|\.svn)\z/ =~ e - sub_suite = recursive_collect(e_name, already_gathered) - sub_suites << sub_suite unless(sub_suite.empty?) - else - next if /~\z/ =~ e_name or /\A\.\#/ =~ e - if @pattern and !@pattern.empty? - next unless @pattern.any? {|pat| pat =~ e_name} - end - if @exclude and !@exclude.empty? - next if @exclude.any? {|pat| pat =~ e_name} - end - collect_file(e_name, sub_suites, already_gathered) - end - end - else - collect_file(name, sub_suites, already_gathered) - end - suite = TestSuite.new(@file.basename(name)) - sort(sub_suites).each{|s| suite << s} - suite - end - - def collect_file(name, suites, already_gathered) - dir = @file.dirname(@file.expand_path(name, @base)) - $:.unshift(dir) - if(@req) - @req.require(name) - else - require(name) - end - find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)} - ensure - $:.delete_at($:.index(dir)) if dir - end - - def realdir(path) - if @base - @file.join(@base, path) - else - path - end - end - end - end - end -end diff --git a/lib/test/unit/collector/objectspace.rb b/lib/test/unit/collector/objectspace.rb deleted file mode 100644 index 4a768c721e..0000000000 --- a/lib/test/unit/collector/objectspace.rb +++ /dev/null @@ -1,40 +0,0 @@ -# Author:: Nathaniel Talbott. -# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. -# License:: Ruby license. - -require 'test/unit/collector' - -module Test - module Unit - module Collector - class ObjectSpace - include Test::Unit::Collector - - NAME = 'collected from the subclasses of TestCase' - - def initialize(source=nil) - super() - @source = source - end - - def collect(name=NAME) - suite = TestSuite.new(name) - sub_suites = [] - 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 - sort(sub_suites).each{|s| suite << s} - suite - end - end - end - end -end |