diff options
Diffstat (limited to 'tool/lib/test/unit/parallel.rb')
-rw-r--r-- | tool/lib/test/unit/parallel.rb | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/tool/lib/test/unit/parallel.rb b/tool/lib/test/unit/parallel.rb index ccaf1a913a..ac297d4a0e 100644 --- a/tool/lib/test/unit/parallel.rb +++ b/tool/lib/test/unit/parallel.rb @@ -1,12 +1,6 @@ # frozen_string_literal: true -$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../.." -require 'test/unit' -require "profile_test_all" if ENV.key?('RUBY_TEST_ALL_PROFILE') -require "tracepointchecker" -require "zombie_hunter" -require "iseq_loader_checker" -require "gc_compact_checker" +require_relative "../../../test/init" module Test module Unit @@ -15,7 +9,6 @@ module Test undef autorun end - alias orig_run_suite mini_run_suite undef _run_suite undef _run_suites undef run @@ -32,12 +25,16 @@ module Test end end + def _start_method(inst) + _report "start", Marshal.dump([inst.class.name, inst.__name__]) + end + def _run_suite(suite, type) # :nodoc: @partial_report = [] - orig_testout = MiniTest::Unit.output + orig_testout = Test::Unit::Runner.output i,o = IO.pipe - MiniTest::Unit.output = o + Test::Unit::Runner.output = o orig_stdin, orig_stdout = $stdin, $stdout th = Thread.new do @@ -58,7 +55,7 @@ module Test result = [nil,nil] end - MiniTest::Unit.output = orig_testout + Test::Unit::Runner.output = orig_testout $stdin = orig_stdin $stdout = orig_stdout @@ -79,7 +76,7 @@ module Test _report "done", Marshal.dump(result) return result ensure - MiniTest::Unit.output = orig_stdout + Test::Unit::Runner.output = orig_stdout $stdin = orig_stdin if orig_stdin $stdout = orig_stdout if orig_stdout o.close if o && !o.closed? @@ -108,12 +105,12 @@ module Test case buf.chomp when /^loadpath (.+?)$/ @old_loadpath = $:.dup - $:.push(*Marshal.load($1.unpack("m")[0].force_encoding("ASCII-8BIT"))).uniq! + $:.push(*Marshal.load($1.unpack1("m").force_encoding("ASCII-8BIT"))).uniq! when /^run (.+?) (.+?)$/ _report "okay" @options = @opts.dup - suites = MiniTest::Unit::TestCase.test_suites + suites = Test::Unit::TestCase.test_suites begin require File.realpath($1) @@ -122,7 +119,7 @@ module Test _report "ready" next end - _run_suites MiniTest::Unit::TestCase.test_suites-suites, $2.to_sym + _run_suites Test::Unit::TestCase.test_suites-suites, $2.to_sym if @need_exit _report "bye" @@ -160,21 +157,21 @@ module Test end def puke(klass, meth, e) # :nodoc: - if e.is_a?(MiniTest::Skip) - new_e = MiniTest::Skip.new(e.message) + if e.is_a?(Test::Unit::PendedError) + new_e = Test::Unit::PendedError.new(e.message) new_e.set_backtrace(e.backtrace) e = new_e end - @partial_report << [klass.name, meth, e.is_a?(MiniTest::Assertion) ? e : ProxyError.new(e)] + @partial_report << [klass.name, meth, e.is_a?(Test::Unit::AssertionFailedError) ? e : ProxyError.new(e)] super end def record(suite, method, assertions, time, error) # :nodoc: case error when nil - when MiniTest::Assertion, MiniTest::Skip + when Test::Unit::AssertionFailedError, Test::Unit::PendedError case error.cause - when nil, MiniTest::Assertion, MiniTest::Skip + when nil, Test::Unit::AssertionFailedError, Test::Unit::PendedError else bt = error.backtrace error = error.class.new(error.message) @@ -183,7 +180,7 @@ module Test else error = ProxyError.new(error) end - _report "record", Marshal.dump([suite.name, method, assertions, time, error]) + _report "record", Marshal.dump([suite.name, method, assertions, time, error, suite.instance_method(method).source_location]) super end end @@ -193,7 +190,7 @@ end if $0 == __FILE__ module Test module Unit - class TestCase < MiniTest::Unit::TestCase # :nodoc: all + class TestCase # :nodoc: all undef on_parallel_worker? def on_parallel_worker? true @@ -205,5 +202,9 @@ if $0 == __FILE__ end end require 'rubygems' + begin + require 'rake' + rescue LoadError + end Test::Unit::Worker.new.run(ARGV) end |