diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/test/unit.rb | 2 | ||||
-rw-r--r-- | lib/test/unit/autorunner.rb | 20 | ||||
-rw-r--r-- | lib/test/unit/collector/dir.rb | 5 |
3 files changed, 16 insertions, 11 deletions
diff --git a/lib/test/unit.rb b/lib/test/unit.rb index 84f221fe96..7c1e2c064b 100644 --- a/lib/test/unit.rb +++ b/lib/test/unit.rb @@ -273,6 +273,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 |