diff options
| author | nagachika <nagachika@ruby-lang.org> | 2024-07-06 13:33:24 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2024-07-06 13:35:22 +0900 |
| commit | 89de66dbb0d8454c9d69faa331d6e35f8b315cce (patch) | |
| tree | dbc4da2af6dff635ab3329283a536a7a851b4093 /test/ruby | |
| parent | 5577e5d396cc8f062833b67d6280db6cc8501e7a (diff) | |
merge revision(s) 78d9fe69479d32214a52ad7291c3973f1b6b7f6f, 04729fe68dceddab045be7324e26c2bb15aa62c7: [Backport #20286] [Backport #20286]
Ensure that exiting thread invokes end-of-life behaviour. (#10039)
Fix exception handling in `rb_fiber_scheduler_set`. (#10042)
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_settracefunc.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index d863ebe985..fa1601b0e3 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -2738,4 +2738,52 @@ CODE Foo.foo RUBY 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 |
