summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--lib/test/unit.rb60
-rw-r--r--lib/test/unit/autorunner.rb20
-rw-r--r--lib/test/unit/collector/dir.rb5
-rw-r--r--test/runner.rb2
5 files changed, 58 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index f4de55dd20..b1fbc165ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Thu Feb 17 11:54: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:09:45 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* test/drb/ignore_test_drb.rb: move TestDRbReusePort to new file
diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index f6f250a5cf..3a1676a330 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -240,35 +240,35 @@ module Test
# class TS_MyTests
# def self.suite
# suite = Test::Unit::TestSuite.new
-# suite << TC_MyFirstTests.suite
-# suite << TC_MoreTestsByMe.suite
-# suite << TS_AnotherSetOfTests.suite
-# return suite
-# end
-# end
-# Test::Unit::UI::Console::TestRunner.run(TS_MyTests)
-#
-# Now, this is a bit cumbersome, so Test::Unit does a little bit more
-# for you, by wrapping these up automatically when you require
-# 'test/unit'. What does this mean? It means you could write the above
-# test case like this instead:
-#
-# require 'test/unit'
-# require 'tc_myfirsttests'
-# require 'tc_moretestsbyme'
-# require 'ts_anothersetoftests'
-#
-# Test::Unit is smart enough to find all the test cases existing in
-# the ObjectSpace and wrap them up into a suite for you. It then runs
-# the dynamic suite using the console TestRunner.
-#
-#
-# == Questions?
-#
-# I'd really like to get feedback from all levels of Ruby
-# practitioners about typos, grammatical errors, unclear statements,
-# missing points, etc., in this document (or any other).
-#
+ # suite << TC_MyFirstTests.suite
+ # suite << TC_MoreTestsByMe.suite
+ # suite << TS_AnotherSetOfTests.suite
+ # return suite
+ # end
+ # end
+ # Test::Unit::UI::Console::TestRunner.run(TS_MyTests)
+ #
+ # Now, this is a bit cumbersome, so Test::Unit does a little bit more
+ # for you, by wrapping these up automatically when you require
+ # 'test/unit'. What does this mean? It means you could write the above
+ # test case like this instead:
+ #
+ # require 'test/unit'
+ # require 'tc_myfirsttests'
+ # require 'tc_moretestsbyme'
+ # require 'ts_anothersetoftests'
+ #
+ # Test::Unit is smart enough to find all the test cases existing in
+ # the ObjectSpace and wrap them up into a suite for you. It then runs
+ # the dynamic suite using the console TestRunner.
+ #
+ #
+ # == Questions?
+ #
+ # I'd really like to get feedback from all levels of Ruby
+ # practitioners about typos, grammatical errors, unclear statements,
+ # missing points, etc., in this document (or any other).
+ #
module Unit
def self.run=(flag)
@run = flag
@@ -282,6 +282,6 @@ end
at_exit do
unless $! || Test::Unit.run?
- exit Test::Unit::AutoRunner.run($0 != "-e" && $0)
+ exit Test::Unit::AutoRunner.run
end
end
diff --git a/lib/test/unit/autorunner.rb b/lib/test/unit/autorunner.rb
index 38b0b76ef3..2831293b7c 100644
--- a/lib/test/unit/autorunner.rb
+++ b/lib/test/unit/autorunner.rb
@@ -5,14 +5,20 @@ require 'optparse'
module Test
module Unit
class AutoRunner
- def self.run(current_file=nil, default_dir=nil, argv=ARGV, &block)
- if(!current_file || current_file == $0)
- r = new(!current_file, &block)
- if !r.process_args(argv) && default_dir
- r.to_run << default_dir
- end
- r.run
+ def self.run(force_standalone=false, default_dir=nil, argv=ARGV, &block)
+ r = new(force_standalone || standalone?, &block)
+ if((!r.process_args(argv)) && default_dir)
+ r.to_run << default_dir
+ end
+ r.run
+ end
+
+ def self.standalone?
+ return false unless("-e" == $0)
+ ObjectSpace.each_object(Class) do |klass|
+ return false if(klass < TestCase)
end
+ true
end
RUNNERS = {
diff --git a/lib/test/unit/collector/dir.rb b/lib/test/unit/collector/dir.rb
index 9342fdecbc..1395cdf4e5 100644
--- a/lib/test/unit/collector/dir.rb
+++ b/lib/test/unit/collector/dir.rb
@@ -75,9 +75,8 @@ module Test
end
def collect_file(name, suites, already_gathered)
- loadpath = $:.dup
dir = File.dirname(File.expand_path(name))
- $:.unshift(dir) unless $:.first == dir
+ $:.unshift(dir)
if(@req)
@req.require(name)
else
@@ -85,7 +84,7 @@ module Test
end
find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)}
ensure
- $:.replace(loadpath)
+ $:.delete_at($:.rindex(dir)) if(dir)
end
end
end
diff --git a/test/runner.rb b/test/runner.rb
index 4ecc35aecc..d274bc8929 100644
--- a/test/runner.rb
+++ b/test/runner.rb
@@ -4,4 +4,4 @@ rcsid = %w$Id$
Version = rcsid[2].scan(/\d+/).collect!(&method(:Integer)).freeze
Release = rcsid[3].freeze
-exit Test::Unit::AutoRunner.run(false, File.dirname($0))
+exit Test::Unit::AutoRunner.run(true, File.dirname($0))