mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
73e4384a23
* 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
53 lines
1.3 KiB
Ruby
53 lines
1.3 KiB
Ruby
require 'test/unit/testsuite'
|
|
require 'test/unit/testcase'
|
|
require 'optparse'
|
|
|
|
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
|
|
suite = Test::Unit::TestSuite.new
|
|
ObjectSpace.each_object(Class) do |klass|
|
|
suite << klass.suite if (Test::Unit::TestCase > klass)
|
|
end
|
|
suite
|
|
end
|
|
end
|
|
|
|
runners_map = {
|
|
'console' => proc do |suite|
|
|
require 'test/unit/ui/console/testrunner'
|
|
passed = Test::Unit::UI::Console::TestRunner.run(suite).passed?
|
|
exit(passed ? 0 : 1)
|
|
end,
|
|
'gtk' => proc do |suite|
|
|
require 'test/unit/ui/gtk/testrunner'
|
|
Test::Unit::UI::GTK::TestRunner.run(suite)
|
|
end,
|
|
'fox' => proc do |suite|
|
|
require 'test/unit/ui/fox/testrunner'
|
|
Test::Unit::UI::Fox::TestRunner.run(suite)
|
|
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)
|