Skip to content

Commit ea5b1f7

Browse files
koji-takao-spclaude
andcommitted
Debug: Add detailed output to finalize tests
- Print debug messages showing which finalizer is being called - Show PIDs being processed - Helps identify exactly where the hang occurs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 986be9e commit ea5b1f7

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

test/finalize_freeze_test.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class LongRunningSchmoozer < Schmooze::Base
2121
# The fix uses `Process.kill(:KILL, pid)` to actually terminate the process
2222
# before waiting for it.
2323
def test_finalizer_does_not_hang
24+
$stderr.puts "[DEBUG] test_finalizer_does_not_hang: start"
2425
finalizer = nil
2526
pid = nil
2627

@@ -33,17 +34,21 @@ def test_finalizer_does_not_hang
3334
# Verify the process is running
3435
assert pid, "Process should be running"
3536
Process.kill(0, pid) # Should not raise if process is running
37+
$stderr.puts "[DEBUG] test_finalizer_does_not_hang: created pid=#{pid}"
3638
end
3739

3840
# Run the finalizer with a timeout to detect hanging
41+
$stderr.puts "[DEBUG] test_finalizer_does_not_hang: calling finalizer..."
3942
assert_raises_nothing_within(5) do
4043
finalizer.call
4144
end
45+
$stderr.puts "[DEBUG] test_finalizer_does_not_hang: finalizer completed"
4246

4347
# Verify the process was killed
4448
assert_raises Errno::ESRCH do
4549
Process.kill(0, pid)
4650
end
51+
$stderr.puts "[DEBUG] test_finalizer_does_not_hang: done"
4752
end
4853

4954
# Test that finalizer properly cleans up multiple instances
@@ -53,21 +58,31 @@ def test_finalizer_handles_multiple_instances_under_gc_pressure
5358
pids = []
5459
finalizers = []
5560

61+
$stderr.puts "[DEBUG] Creating 5 schmoozer instances..."
5662
ObjectSpace.stub :define_finalizer, proc { |_s, p| finalizers << p } do
57-
5.times do
63+
5.times do |i|
5864
schmoozer = LongRunningSchmoozer.new(__dir__)
5965
schmoozer.echo("test")
6066
pids << schmoozer.pid
67+
$stderr.puts "[DEBUG] Created instance #{i+1}, pid=#{schmoozer.pid}"
6168
end
6269
end
6370

6471
assert_equal 5, pids.length
6572
assert_equal 5, finalizers.length
6673

74+
$stderr.puts "[DEBUG] Calling finalizers..."
6775
# All finalizers should complete without hanging
6876
assert_raises_nothing_within(15) do
69-
finalizers.each(&:call)
77+
finalizers.each_with_index do |finalizer, i|
78+
$stderr.puts "[DEBUG] Calling finalizer #{i+1} for pid=#{pids[i]}..."
79+
$stderr.flush
80+
finalizer.call
81+
$stderr.puts "[DEBUG] Finalizer #{i+1} completed"
82+
$stderr.flush
83+
end
7084
end
85+
$stderr.puts "[DEBUG] All finalizers completed"
7186

7287
# All processes should be terminated
7388
pids.each do |pid|

0 commit comments

Comments
 (0)