Hi,

At Mon, 8 Dec 2003 01:47:18 +0900,
Sean E. Russell wrote:
> > I guess this "require" line is no longer needed.  This would
> > cause loop at loading.
> 
> Thanks, that was it.  
> 
> If I want backwards compatibility, is the only fix to catch the exception?

The problem is caused by cyclic requiring between
test/unit/autorunner.rb, test/unit/ui/console/testrunner.rb,
test/unit/ui/testrunnermediator.rb and test/unit.rb.

When you require test/unit/ui/console/testrunner.rb, required
test/unit/autorunner.rb requires former again, but it ends with
no effect because it is under loading already, and constants
defined in it cannot be accessed.

In short, the point is that AutoRunner is depending on a particular
test runner, I guess.  And, the other runners never use them?


* lib/test/unit/autorunner.rb: remove dependency to a particular
  runner.  [ruby-core:01901], [ruby-list:38869]

* lib/test/unit/ui/testrunnerutilities.rb: moved output level
  constants from Console.

* lib/test/unit/ui/console/testrunner.rb: ditto.

* lib/test/unit/ui/{fox,gtk,gtk2,tk}/testrunner.rb (initialize):
  accept output_level.

Index: lib/test/unit/autorunner.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/test/unit/autorunner.rb,v retrieving revision 1.6 diff -u -2 -p -d -r1.6 autorunner.rb --- lib/test/unit/autorunner.rb 2 Dec 2003 12:31:44 -0000 1.6 +++ lib/test/unit/autorunner.rb 8 Dec 2003 07:23:35 -0000 @@ -1,6 +1,5 @@ +require 'test/unit/ui/testrunnerutilities' require 'optparse' -require 'test/unit/ui/console/testrunner' - module Test module Unit @@ -18,29 +17,30 @@ module Test RUNNERS = { :console => proc do |r| - Test::Unit::UI::Console::TestRunner.run(r.suite, r.output_level) + require 'test/unit/ui/console/testrunner' + Test::Unit::UI::Console::TestRunner end, :gtk => proc do |r| require 'test/unit/ui/gtk/testrunner' - Test::Unit::UI::GTK::TestRunner.run(r.suite) + Test::Unit::UI::GTK::TestRunner end, :gtk2 => proc do |r| require 'test/unit/ui/gtk2/testrunner' - Test::Unit::UI::GTK2::TestRunner.run(r.suite) + Test::Unit::UI::GTK2::TestRunner end, :fox => proc do |r| require 'test/unit/ui/fox/testrunner' - Test::Unit::UI::Fox::TestRunner.run(r.suite) + Test::Unit::UI::Fox::TestRunner end, :tk => proc do |r| require 'test/unit/ui/tk/testrunner' - Test::Unit::UI::Tk::TestRunner.run(r.suite) + Test::Unit::UI::Tk::TestRunner end, } OUTPUT_LEVELS = { - :silent => UI::Console::TestRunner::SILENT, - :progress => UI::Console::TestRunner::PROGRESS_ONLY, - :normal => UI::Console::TestRunner::NORMAL, - :verbose => UI::Console::TestRunner::VERBOSE, + :silent => UI::SILENT, + :progress => UI::PROGRESS_ONLY, + :normal => UI::NORMAL, + :verbose => UI::VERBOSE, } @@ -72,5 +72,5 @@ module Test @filters = [] @to_run = [] - @output_level = Test::Unit::UI::Console::TestRunner::NORMAL + @output_level = UI::NORMAL yield(self) if(block_given?) end @@ -181,5 +181,5 @@ module Test @suite = @collector[self] result = @runner[self] or return false - result.passed? + result.run(@suite, @output_level).passed? end end Index: lib/test/unit/ui/testrunnerutilities.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/test/unit/ui/testrunnerutilities.rb,v retrieving revision 1.1.1.2 diff -u -2 -p -d -r1.1.1.2 testrunnerutilities.rb --- lib/test/unit/ui/testrunnerutilities.rb 12 Feb 2003 04:22:33 -0000 1.1.1.2 +++ lib/test/unit/ui/testrunnerutilities.rb 8 Dec 2003 07:15:12 -0000 @@ -9,4 +9,9 @@ module Test module UI + SILENT = 0 + PROGRESS_ONLY = 1 + NORMAL = 2 + VERBOSE = 3 + # Provides some utilities common to most, if not all, # TestRunners. Index: lib/test/unit/ui/console/testrunner.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/test/unit/ui/console/testrunner.rb,v retrieving revision 1.3 diff -u -2 -p -d -r1.3 testrunner.rb --- lib/test/unit/ui/console/testrunner.rb 19 Sep 2003 02:48:46 -0000 1.3 +++ lib/test/unit/ui/console/testrunner.rb 8 Dec 2003 07:16:22 -0000 @@ -17,9 +17,4 @@ module Test extend TestRunnerUtilities - SILENT = 0 - PROGRESS_ONLY = 1 - NORMAL = 2 - VERBOSE = 3 - # Creates a new TestRunner and runs the suite. def self.run(suite, output_level=NORMAL) Index: lib/test/unit/ui/fox/testrunner.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/test/unit/ui/fox/testrunner.rb,v retrieving revision 1.2 diff -u -2 -p -d -r1.2 testrunner.rb --- lib/test/unit/ui/fox/testrunner.rb 2 Dec 2003 12:31:44 -0000 1.2 +++ lib/test/unit/ui/fox/testrunner.rb 8 Dec 2003 07:20:33 -0000 @@ -35,5 +35,5 @@ module Test # Creates a new TestRunner for running the passed # suite. - def initialize(suite) + def initialize(suite, output_level = NORMAL) if (suite.respond_to?(:suite)) @suite = suite.suite 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.6 diff -u -2 -p -d -r1.6 testrunner.rb --- lib/test/unit/ui/gtk/testrunner.rb 2 Dec 2003 12:31:44 -0000 1.6 +++ lib/test/unit/ui/gtk/testrunner.rb 8 Dec 2003 07:20:06 -0000 @@ -28,5 +28,5 @@ module Test # Creates a new TestRunner for running the passed # suite. - def initialize(suite) + def initialize(suite, output_level = NORMAL) if (suite.respond_to?(:suite)) @suite = suite.suite 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.4 diff -u -2 -p -d -r1.4 testrunner.rb --- lib/test/unit/ui/gtk2/testrunner.rb 2 Dec 2003 12:41:01 -0000 1.4 +++ lib/test/unit/ui/gtk2/testrunner.rb 8 Dec 2003 07:20:19 -0000 @@ -441,5 +441,5 @@ module Test end # def start - def initialize(suite) + def initialize(suite, output_level = NORMAL) if suite.respond_to?(:suite) then @suite = suite.suite 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.6 diff -u -2 -p -d -r1.6 testrunner.rb --- lib/test/unit/ui/tk/testrunner.rb 2 Dec 2003 12:31:44 -0000 1.6 +++ lib/test/unit/ui/tk/testrunner.rb 8 Dec 2003 07:19:54 -0000 @@ -29,5 +29,5 @@ module Test # Creates a new TestRunner for running the passed # suite. - def initialize(suite) + def initialize(suite, output_level = NORMAL) if (suite.respond_to?(:suite)) @suite = suite.suite
-- Nobu Nakada