* lib/test/unit/collector.rb (collect_file): now deletes paths added

to $LOAD_PATH instead of restoring it verbatim.

	* lib/test/unit/autorunner.rb (AutoRunner.run): fixed so that
	  'ruby -rtest/unit -rtest1 -rtest2 -e0' will use the objectspace
	  collector again. Also tried to simplify the calling convention.

	* test/runner.rb: adjusted for new AutoRunner semantics.

	* lib/test/unit.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ntalbott 2005-02-17 04:50:49 +00:00
parent 966332ebed
commit f2d29b01cb
5 changed files with 29 additions and 12 deletions

View File

@ -1,3 +1,15 @@
Thu Feb 17 13:46:00 2005 Nathaniel Talbott <ntalbott@ruby-lang.org>
* lib/test/unit/collector.rb (collect_file): now deletes paths added
to $LOAD_PATH instead of restoring it verbatim.
* lib/test/unit/autorunner.rb (AutoRunner.run): fixed so that
'ruby -rtest/unit -rtest1 -rtest2 -e0' will use the objectspace
collector again. Also tried to simplify the calling convention.
* test/runner.rb: adjusted for new AutoRunner semantics.
* lib/test/unit.rb: ditto.
Thu Feb 17 00:31:21 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp> Thu Feb 17 00:31:21 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/drb/test_drb.rb, ut_safe1.rb: port from 1.8 * test/drb/test_drb.rb, ut_safe1.rb: port from 1.8

View File

@ -273,6 +273,6 @@ end
at_exit do at_exit do
unless $! || Test::Unit.run? unless $! || Test::Unit.run?
exit Test::Unit::AutoRunner.run($0 != "-e" && $0) exit Test::Unit::AutoRunner.run
end end
end end

View File

@ -5,14 +5,20 @@ require 'optparse'
module Test module Test
module Unit module Unit
class AutoRunner class AutoRunner
def self.run(current_file=nil, default_dir=nil, argv=ARGV, &block) def self.run(force_standalone=false, default_dir=nil, argv=ARGV, &block)
if(!current_file || current_file == $0) r = new(force_standalone || standalone?, &block)
r = new(!current_file, &block) if((!r.process_args(argv)) && default_dir)
if !r.process_args(argv) && default_dir
r.to_run << default_dir r.to_run << default_dir
end end
r.run r.run
end end
def self.standalone?
return false unless("-e" == $0)
ObjectSpace.each_object(Class) do |klass|
return false if(klass < TestCase)
end
true
end end
RUNNERS = { RUNNERS = {

View File

@ -75,9 +75,8 @@ module Test
end end
def collect_file(name, suites, already_gathered) def collect_file(name, suites, already_gathered)
loadpath = $:.dup
dir = File.dirname(File.expand_path(name)) dir = File.dirname(File.expand_path(name))
$:.unshift(dir) unless $:.first == dir $:.unshift(dir)
if(@req) if(@req)
@req.require(name) @req.require(name)
else else
@ -85,7 +84,7 @@ module Test
end end
find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)} find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)}
ensure ensure
$:.replace(loadpath) $:.delete_at($:.rindex(dir)) if(dir)
end end
end end
end end

View File

@ -6,4 +6,4 @@ rcsid = %w$Id$
Version = rcsid[2].scan(/\d+/).collect!(&method(:Integer)).freeze Version = rcsid[2].scan(/\d+/).collect!(&method(:Integer)).freeze
Release = rcsid[3].freeze Release = rcsid[3].freeze
exit Test::Unit::AutoRunner.run(false, File.dirname($0)) exit Test::Unit::AutoRunner.run(true, File.dirname($0))