summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Endoh <[email protected]>2024-08-06 20:09:42 +0900
committerYusuke Endoh <[email protected]>2024-08-06 21:11:41 +0900
commit062f85e141e4fb806b5d4b6dbf6a8cb1f3ce682d (patch)
treeacd540b47122dbb1e59a659b0e4855c060466692
parent67cd95e68fbeb8db005c2dfbdbd5da979ea8a3b8 (diff)
Dump all-thread backtraces when test parallel worker exceeds time limit
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11315
-rw-r--r--tool/lib/test/unit.rb6
-rw-r--r--tool/lib/test/unit/parallel.rb13
-rw-r--r--tool/test/testunit/test_parallel.rb4
3 files changed, 17 insertions, 6 deletions
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