* lib/test/unit.rb: MiniTest::Unit is different class from

Test::Unit, and install runner before loading test/minitest.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-07-17 01:08:04 +00:00
Родитель d98d3fe12a
Коммит 43f3e3779c
4 изменённых файлов: 46 добавлений и 9 удалений

Просмотреть файл

@ -1,7 +1,7 @@
Fri Jul 16 22:08:10 2010 Yusuke Endoh <mame@tsg.ne.jp>
Sat Jul 17 10:07:52 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit.rb, bin/testrb, test/runner.rb: revert r28655, which
broke test-all.
* lib/test/unit.rb: MiniTest::Unit is different class from
Test::Unit, and install runner before loading test/minitest.
Fri Jul 16 14:58:38 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>

Просмотреть файл

@ -1,9 +1,9 @@
#!/usr/bin/env ruby
require 'test/unit'
Test::Unit.setup_argv {|files|
exit Test::Unit.start {|files|
if files.empty?
puts "Usage: testrb [options] tests..."
exit 1
exit false
end
if files.size == 1
$0 = File.basename(files[0])

Просмотреть файл

@ -9,7 +9,20 @@ module Test
module Unit
TEST_UNIT_IMPLEMENTATION = 'test/unit compatibility layer using minitest'
def self.setup_argv(original_argv=ARGV)
module RunCount
@@run_count = 0
def self.have_run?
@@run_count.nonzero?
end
def run(*)
@@run_count += 1
super
end
end
def self.setup_argv(original_argv=::ARGV)
minitest_argv = []
files = []
reject = []
@ -55,6 +68,12 @@ module Test
reject_pat = Regexp.union(reject.map {|r| /#{r}/ })
files.reject! {|f| reject_pat =~ f }
MiniTest::Unit._install_at_exit {
next if RunCount.have_run?
next if $! # don't run if there was an exception
exit false unless run(minitest_argv)
}
files.each {|f|
d = File.dirname(path = File.expand_path(f))
unless $:.include? d
@ -67,9 +86,27 @@ module Test
end
}
ARGV.replace minitest_argv
minitest_argv
end
def self.run(args)
exit_code = MiniTest::Unit.new.run(args)
!exit_code || exit_code == 0
end
def self.start(argv=::ARGV, &block)
run(setup_argv(argv, &block))
end
end
end
MiniTest::Unit.autorun
class MiniTest::Unit
def self.new(*)
super.extend(Test::Unit::RunCount)
end
def self._install_at_exit(&block)
at_exit(&block) unless @@installed_at_exit
@@installed_at_exit = true
end
end

Просмотреть файл

@ -6,7 +6,7 @@ require 'test/unit'
src_testdir = File.dirname(File.expand_path(__FILE__))
srcdir = File.dirname(src_testdir)
Test::Unit.setup_argv {|files|
exit Test::Unit.start {|files|
if files.empty?
[src_testdir]
else