diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 18b894a893..0eb8ab4c6d 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -406,10 +406,10 @@ module Test rescue IOError end - def quit + def quit(reason = :normal) return if @io.closed? @quit_called = true - @io.puts "quit" + @io.puts "quit #{reason}" rescue Errno::EPIPE => e warn "#{@pid}:#{@status.to_s.ljust(7)}:#{@file}: #{e.message}" end @@ -534,7 +534,7 @@ module Test next unless cond&.call(worker) begin Timeout.timeout(1) do - worker.quit + worker.quit(cond ? :timeout : :normal) end rescue Errno::EPIPE rescue Timeout::Error diff --git a/tool/lib/test/unit/parallel.rb b/tool/lib/test/unit/parallel.rb index ac297d4a0e..db14ca9d13 100644 --- a/tool/lib/test/unit/parallel.rb +++ b/tool/lib/test/unit/parallel.rb @@ -127,7 +127,18 @@ module Test else _report "ready" end - when /^quit$/ + when /^quit (.+?)$/, "quit" + if $1 == "timeout" + err = ["", "!!! worker #{$$} killed due to timeout:"] + Thread.list.each do |th| + err << "#{ th.inspect }:" + th.backtrace.each do |s| + err << " #{ s }" + end + end + err << "" + $STDERR.puts err.join("\n") + end _report "bye" exit end diff --git a/tool/test/testunit/test_parallel.rb b/tool/test/testunit/test_parallel.rb index 6882fd6c5f..371e8524c1 100644 --- a/tool/test/testunit/test_parallel.rb +++ b/tool/test/testunit/test_parallel.rb @@ -22,7 +22,7 @@ module TestParallel if @worker_pid && @worker_in begin begin - @worker_in.puts "quit" + @worker_in.puts "quit normal" rescue IOError, Errno::EPIPE end Timeout.timeout(2) do @@ -136,7 +136,7 @@ module TestParallel def test_quit Timeout.timeout(TIMEOUT) do - @worker_in.puts "quit" + @worker_in.puts "quit normal" assert_match(/^bye$/m,@worker_out.read) end end