Hi,

Now test/unit terminates whole process at the end of tests,
however, I feel a library should not do it.  So made a patch
which removes exit from test/unit to applications.  And this
moves some stuff in test/runner.rb to AutoRunner, reversely.

How do you think this, Nathaniel?


Index: lib/test/unit/autorunner.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/test/unit/autorunner.rb,v retrieving revision 1.5 diff -u -2 -p -r1.5 autorunner.rb --- lib/test/unit/autorunner.rb 17 Nov 2003 00:41:40 -0000 1.5 +++ lib/test/unit/autorunner.rb 1 Dec 2003 03:17:12 -0000 @@ -6,9 +6,9 @@ module Test module Unit class AutoRunner - def self.run(current_file=nil, default_dir=nil, &block) + def self.run(current_file=nil, default_dir=nil, to_run=ARGV, &block) if(!current_file || current_file == $0) - r = new(!current_file, &block) - if(default_dir && r.to_run.empty?) - r.to_run = default_dir + r = new(!current_file, to_run, &block) + if default_dir ||= (File.directory(current_file) if current_file) && r.to_run.empty? + r.to_run << default_dir end r.run @@ -19,6 +19,5 @@ module Test :console => proc do |r| output_level = r.output_level || Test::Unit::UI::Console::TestRunner::NORMAL - passed = Test::Unit::UI::Console::TestRunner.run(r.suite, output_level).passed? - exit(passed ? 0 : 1) + Test::Unit::UI::Console::TestRunner.run(r.suite, output_level) end, :gtk => proc do |r| @@ -67,5 +66,5 @@ module Test attr_writer :runner, :collector - def initialize(standalone) + def initialize(standalone, to_run = nil) Unit.run = true @standalone = standalone @@ -73,5 +72,5 @@ module Test @collector = COLLECTORS[(standalone ? :dir : :objectspace)] @filters = [] - @to_run = [] + *@to_run = *(to_run || []) process_args yield(self) if(block_given?) @@ -180,5 +179,5 @@ module Test def run @suite = @collector[self] - @runner[self] + @runner[self].passed? end end Index: lib/test/unit/ui/gtk/testrunner.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/test/unit/ui/gtk/testrunner.rb,v retrieving revision 1.5 diff -u -2 -p -r1.5 testrunner.rb --- lib/test/unit/ui/gtk/testrunner.rb 27 Nov 2003 15:34:53 -0000 1.5 +++ lib/test/unit/ui/gtk/testrunner.rb 1 Dec 2003 02:49:16 -0000 @@ -95,5 +95,4 @@ module Test rescue end - exit !@red end Index: lib/test/unit/ui/gtk2/testrunner.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/test/unit/ui/gtk2/testrunner.rb,v retrieving revision 1.2 diff -u -2 -p -r1.2 testrunner.rb --- lib/test/unit/ui/gtk2/testrunner.rb 27 Nov 2003 15:34:53 -0000 1.2 +++ lib/test/unit/ui/gtk2/testrunner.rb 1 Dec 2003 02:53:57 -0000 @@ -407,5 +407,4 @@ module Test rescue end - exit !@red end # def start_ui private :start_ui Index: lib/test/unit/ui/tk/testrunner.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/test/unit/ui/tk/testrunner.rb,v retrieving revision 1.5 diff -u -2 -p -r1.5 testrunner.rb --- lib/test/unit/ui/tk/testrunner.rb 27 Nov 2003 15:34:53 -0000 1.5 +++ lib/test/unit/ui/tk/testrunner.rb 1 Dec 2003 02:53:51 -0000 @@ -103,5 +103,4 @@ module Test rescue end - exit !@red end Index: test/runner.rb =================================================================== RCS file: /cvs/ruby/src/ruby/test/runner.rb,v retrieving revision 1.10 diff -u -2 -p -r1.10 runner.rb --- test/runner.rb 13 Oct 2003 14:57:36 -0000 1.10 +++ test/runner.rb 1 Dec 2003 03:10:07 -0000 @@ -5,6 +5,3 @@ Version = rcsid[2].scan(/\d+/).collect!( Release = rcsid[3].freeze -runner = Test::Unit::AutoRunner.new(true) -runner.to_run.concat(ARGV) -runner.to_run << File.dirname(__FILE__) if runner.to_run.empty? -runner.run +exit Test::Unit::AutoRunner.run($0)
-- Nobu Nakada