summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2024-05-29 10:02:15 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2024-05-29 10:02:15 -0700
commita8b2317d16fa172edd3cd7e6fcb3bc694287d109 (patch)
tree322eaa670f8c69e51e303001780da1d8ee146651 /test/ruby
parent6aaf673e4d3fa1f8a90e6006aadefddcb87fe1de (diff)
merge revision(s) 78d9fe69479d32214a52ad7291c3973f1b6b7f6f: [Backport #20286]
Ensure that exiting thread invokes end-of-life behaviour. (#10039)
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_settracefunc.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index dbaf0aaf09..a90c885247 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -2874,4 +2874,52 @@ CODE
assert err.kind_of?(RuntimeError)
assert_equal err.message.to_i + 3, line
end
+
+ def test_tracepoint_thread_begin
+ target_thread = nil
+
+ trace = TracePoint.new(:thread_begin) do |tp|
+ target_thread = tp.self
+ end
+
+ trace.enable(target_thread: nil) do
+ Thread.new{}.join
+ end
+
+ assert_kind_of(Thread, target_thread)
+ end
+
+ def test_tracepoint_thread_end
+ target_thread = nil
+
+ trace = TracePoint.new(:thread_end) do |tp|
+ target_thread = tp.self
+ end
+
+ trace.enable(target_thread: nil) do
+ Thread.new{}.join
+ end
+
+ assert_kind_of(Thread, target_thread)
+ end
+
+ def test_tracepoint_thread_end_with_exception
+ target_thread = nil
+
+ trace = TracePoint.new(:thread_end) do |tp|
+ target_thread = tp.self
+ end
+
+ trace.enable(target_thread: nil) do
+ thread = Thread.new do
+ Thread.current.report_on_exception = false
+ raise
+ end
+
+ # Ignore the exception raised by the thread:
+ thread.join rescue nil
+ end
+
+ assert_kind_of(Thread, target_thread)
+ end
end