From e67e930462b781f09e412e161c4ed8515640bdb2 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 8 Dec 2003 13:48:14 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +++++++++++++ lib/test/unit/autorunner.rb | 26 ++++++++++++------------- lib/test/unit/ui/console/testrunner.rb | 5 ----- lib/test/unit/ui/fox/testrunner.rb | 2 +- lib/test/unit/ui/gtk/testrunner.rb | 2 +- lib/test/unit/ui/gtk2/testrunner.rb | 2 +- lib/test/unit/ui/testrunnerutilities.rb | 5 +++++ lib/test/unit/ui/tk/testrunner.rb | 2 +- 8 files changed, 35 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33837ca0c1f4ea..ee84e66ed19cbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Mon Dec 8 22:48:03 2003 Nobuyoshi Nakada + + * 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. + Mon Dec 8 15:03:30 2003 Nobuyoshi Nakada * ext/syck/syck.c (syck_io_str_read): get rid of buffer overflow. diff --git a/lib/test/unit/autorunner.rb b/lib/test/unit/autorunner.rb index 49fe5435503eab..76c3100472c266 100644 --- a/lib/test/unit/autorunner.rb +++ b/lib/test/unit/autorunner.rb @@ -1,7 +1,6 @@ +require 'test/unit/ui/testrunnerutilities' require 'optparse' -require 'test/unit/ui/console/testrunner' - module Test module Unit class AutoRunner @@ -17,31 +16,32 @@ def self.run(current_file=nil, default_dir=nil, argv=ARGV, &block) 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, } COLLECTORS = { @@ -71,7 +71,7 @@ def initialize(standalone) @collector = COLLECTORS[(standalone ? :dir : :objectspace)] @filters = [] @to_run = [] - @output_level = Test::Unit::UI::Console::TestRunner::NORMAL + @output_level = UI::NORMAL yield(self) if(block_given?) end @@ -180,7 +180,7 @@ def keyword_display(array) def run @suite = @collector[self] result = @runner[self] or return false - result.passed? + result.run(@suite, @output_level).passed? end end end diff --git a/lib/test/unit/ui/console/testrunner.rb b/lib/test/unit/ui/console/testrunner.rb index dab07ddbc4edce..761777195b9392 100644 --- a/lib/test/unit/ui/console/testrunner.rb +++ b/lib/test/unit/ui/console/testrunner.rb @@ -16,11 +16,6 @@ module Console # :nodoc: class TestRunner 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) return new(suite, output_level).start diff --git a/lib/test/unit/ui/fox/testrunner.rb b/lib/test/unit/ui/fox/testrunner.rb index b3c0ce0e401aaf..d89e8c2c878236 100644 --- a/lib/test/unit/ui/fox/testrunner.rb +++ b/lib/test/unit/ui/fox/testrunner.rb @@ -34,7 +34,7 @@ def self.run(suite) # 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 else diff --git a/lib/test/unit/ui/gtk/testrunner.rb b/lib/test/unit/ui/gtk/testrunner.rb index 14fbce25733935..85b873f5fff3fb 100644 --- a/lib/test/unit/ui/gtk/testrunner.rb +++ b/lib/test/unit/ui/gtk/testrunner.rb @@ -27,7 +27,7 @@ def self.run(suite) # 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 else diff --git a/lib/test/unit/ui/gtk2/testrunner.rb b/lib/test/unit/ui/gtk2/testrunner.rb index 2978d100876cb5..3ee6ce87bdb38b 100644 --- a/lib/test/unit/ui/gtk2/testrunner.rb +++ b/lib/test/unit/ui/gtk2/testrunner.rb @@ -440,7 +440,7 @@ def start @result end # def start - def initialize(suite) + def initialize(suite, output_level = NORMAL) if suite.respond_to?(:suite) then @suite = suite.suite else diff --git a/lib/test/unit/ui/testrunnerutilities.rb b/lib/test/unit/ui/testrunnerutilities.rb index 69811608c2796f..4c3148b8be98da 100644 --- a/lib/test/unit/ui/testrunnerutilities.rb +++ b/lib/test/unit/ui/testrunnerutilities.rb @@ -8,6 +8,11 @@ module Test module Unit module UI + SILENT = 0 + PROGRESS_ONLY = 1 + NORMAL = 2 + VERBOSE = 3 + # Provides some utilities common to most, if not all, # TestRunners. # diff --git a/lib/test/unit/ui/tk/testrunner.rb b/lib/test/unit/ui/tk/testrunner.rb index 9e444ca9ac5c99..2bd51deebb0c89 100644 --- a/lib/test/unit/ui/tk/testrunner.rb +++ b/lib/test/unit/ui/tk/testrunner.rb @@ -28,7 +28,7 @@ def self.run(suite) # 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 else