diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/test/unit.rb | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/lib/test/unit.rb b/lib/test/unit.rb index 4aecc49450..b518426893 100644 --- a/lib/test/unit.rb +++ b/lib/test/unit.rb @@ -9,7 +9,21 @@ module Test module Unit TEST_UNIT_IMPLEMENTATION = 'test/unit compatibility layer using minitest' - def self.setup_argv(original_argv=ARGV) + @@installed_at_exit = true + @@run_count = 0 + + RunCount = Module.new do + def run(*) + @@run_count += 1 + super + end + end + + def self.new(*) + super.extend(RunCount) + end + + def self.setup_argv(original_argv=::ARGV) minitest_argv = [] files = [] reject = [] @@ -67,9 +81,23 @@ module Test end } - ARGV.replace minitest_argv + at_exit { + next if @@run_count.nonzero? + next if $! # don't run if there was an exception + exit false unless run(minitest_argv) + } unless @@installed_at_exit + @@installed_at_exit = true + + 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 |