From 73e4384a23b61761cc9fa013e28b290393569d09 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 5 Sep 2003 02:32:24 +0000 Subject: * lib/optparse.rb (--version): fix assignment/reference order. * lib/optparse.rb (OptionParser#help): new; OptionParser#to_s may be deprecated in future. * lib/optparse/version.rb (OptionParser#show_version): hide Object. * test/runner.rb: fix optparse usage. * test/runner.rb: glob all testsuits if no tests given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 +++++++++++++ lib/optparse.rb | 9 +++++---- lib/optparse/date.rb | 2 +- lib/optparse/version.rb | 14 +++++++++++++- test/runner.rb | 31 +++++++++++++++++++++---------- 5 files changed, 53 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88cca86596..1abdec62d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Fri Sep 5 11:32:17 2003 Nobuyoshi Nakada + + * lib/optparse.rb (--version): fix assignment/reference order. + + * lib/optparse.rb (OptionParser#help): new; OptionParser#to_s may + be deprecated in future. + + * lib/optparse/version.rb (OptionParser#show_version): hide Object. + + * test/runner.rb: fix optparse usage. + + * test/runner.rb: glob all testsuits if no tests given. + Fri Sep 5 10:42:58 2003 NAKAMURA, Hiroshi * test/runner.rb: added. gets testcases from command line and runs it. diff --git a/lib/optparse.rb b/lib/optparse.rb index 5281dbbbd7..83f2f7bdcc 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -620,7 +620,7 @@ Default options, which never appear in option summary. end end unless pkg - puts v if v = ARGV.options.ver + v = ARGV.options.ver and puts v end exit end @@ -860,11 +860,12 @@ Default options, which never appear in option summary. end =begin ---- OptionParser#to_str +--- OptionParser#help --- OptionParser#to_s Returns option summary string. =end #'#"#`# - def to_s; summarize(banner.to_s.sub(/\n?\z/, "\n")) end + def help; summarize(banner.to_s.sub(/\n?\z/, "\n")) end + alias to_s help =begin --- OptionParser#to_a @@ -976,7 +977,7 @@ Default options, which never appear in option summary. raise ArgumentError, "argument pattern given twice" end if Array === o - o.each {|o| pattern[(Array === o ? o.shift : o)] = o} + o.each {|o| pattern[(Array === o ? o[0] : o)] = o} else pattern.update(o) end diff --git a/lib/optparse/date.rb b/lib/optparse/date.rb index c9f072f290..d680559f37 100644 --- a/lib/optparse/date.rb +++ b/lib/optparse/date.rb @@ -10,7 +10,7 @@ OptionParser.accept(DateTime) do |s,| end OptionParser.accept(Date) do |s,| begin - DateTime.parse(s) if s + Date.parse(s) if s rescue ArgumentError raise OptionParser::InvalidArgument, s end diff --git a/lib/optparse/version.rb b/lib/optparse/version.rb index 35152181b0..8a1efcdf8c 100644 --- a/lib/optparse/version.rb +++ b/lib/optparse/version.rb @@ -5,7 +5,9 @@ class << OptionParser progname = ARGV.options.program_name show = proc do |klass, version| version = version.join(".") if Array === version - str = "#{progname}: #{klass} version #{version}" + str = "#{progname}" + str << ": #{klass}" unless klass == Object + str << " version #{version}" if klass.const_defined?(:Release) str << " (#{klass.const_get(:Release)})" end @@ -27,6 +29,16 @@ class << OptionParser exit end + def each_const(path, klass = ::Object) + path.split(/::|\//).inject(klass) do |klass, name| + raise NameError, path unless Module === klass + klass.constants.grep(/#{name}/i) do |c| + klass.const_defined?(c) or next + c = klass.const_get(c) + end + end + end + def search_const(klass, name) klasses = [klass] while klass = klasses.shift diff --git a/test/runner.rb b/test/runner.rb index bae7116ea8..d8b981743f 100644 --- a/test/runner.rb +++ b/test/runner.rb @@ -2,16 +2,9 @@ require 'test/unit/testsuite' require 'test/unit/testcase' require 'optparse' -runner = 'console' -opt = OptionParser.new -opt.on("--runner=console", String) do |arg| - runner = arg -end -opt.parse!(ARGV) - -ARGV.each do |tc_name| - require tc_name -end +Revision = %w$Revision$[1..-1] +(Runner = Revision[0]).chomp!(",v") +Version = Revision[1].scan(/\d+/, &method(:Integer)) class BulkTestSuite < Test::Unit::TestSuite def self.suite @@ -39,4 +32,22 @@ runners_map = { end, } +runner = 'console' +ARGV.options do |opt| + opt.program_name = Runner + opt.banner << " [tests...]" + opt.on("--runner=mode", runners_map, "UI mode (console, gtk,fox)") do |arg| + runner = arg + end + opt.parse! +end or abort(ARGV.options.help) + +if ARGV.empty? + ARGV.replace(Dir.glob(File.join(File.dirname(__FILE__), "**", "test_*.rb")).sort) +end + +ARGV.each do |tc_name| + require tc_name +end + runners_map[runner].call(BulkTestSuite.suite) -- cgit v1.2.3