1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
parent d98d3fe12a
commit 43f3e3779c
4 changed files with 46 additions and 9 deletions

View file

@ -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 * lib/test/unit.rb: MiniTest::Unit is different class from
broke test-all. Test::Unit, and install runner before loading test/minitest.
Fri Jul 16 14:58:38 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> Fri Jul 16 14:58:38 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>

View file

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

View file

@ -9,7 +9,20 @@ module Test
module Unit module Unit
TEST_UNIT_IMPLEMENTATION = 'test/unit compatibility layer using minitest' 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 = [] minitest_argv = []
files = [] files = []
reject = [] reject = []
@ -55,6 +68,12 @@ module Test
reject_pat = Regexp.union(reject.map {|r| /#{r}/ }) reject_pat = Regexp.union(reject.map {|r| /#{r}/ })
files.reject! {|f| reject_pat =~ f } 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| files.each {|f|
d = File.dirname(path = File.expand_path(f)) d = File.dirname(path = File.expand_path(f))
unless $:.include? d unless $:.include? d
@ -67,9 +86,27 @@ module Test
end 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 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

View file

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