diff options
Diffstat (limited to 'spec/ruby/core/tracepoint/enable_spec.rb')
-rw-r--r-- | spec/ruby/core/tracepoint/enable_spec.rb | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/spec/ruby/core/tracepoint/enable_spec.rb b/spec/ruby/core/tracepoint/enable_spec.rb index ab392c7583..6cc8bb3897 100644 --- a/spec/ruby/core/tracepoint/enable_spec.rb +++ b/spec/ruby/core/tracepoint/enable_spec.rb @@ -57,25 +57,50 @@ describe 'TracePoint#enable' do end.enable { event_name.should equal(:line) } end - it 'enables the trace object for any thread' do - threads = [] - trace = TracePoint.new(:line) do |tp| - # Runs on purpose on any Thread - threads << Thread.current - end + ruby_version_is '3.2' do + it 'enables the trace object only for the current thread' do + threads = [] + trace = TracePoint.new(:line) do |tp| + # Runs on purpose on any Thread + threads << Thread.current + end - thread = nil - trace.enable do - line_event = true - thread = Thread.new do - event_in_other_thread = true + thread = nil + trace.enable do + line_event = true + thread = Thread.new do + event_in_other_thread = true + end + thread.join end - thread.join + + threads = threads.uniq + threads.should.include?(Thread.current) + threads.should_not.include?(thread) end + end + + ruby_version_is ''...'3.2' do + it 'enables the trace object for any thread' do + threads = [] + trace = TracePoint.new(:line) do |tp| + # Runs on purpose on any Thread + threads << Thread.current + end + + thread = nil + trace.enable do + line_event = true + thread = Thread.new do + event_in_other_thread = true + end + thread.join + end - threads = threads.uniq - threads.should.include?(Thread.current) - threads.should.include?(thread) + threads = threads.uniq + threads.should.include?(Thread.current) + threads.should.include?(thread) + end end it 'can accept arguments within a block but it should not yield arguments' do @@ -124,13 +149,7 @@ describe 'TracePoint#enable' do describe "when nested" do before do - ruby_version_is ""..."3.0" do - @path_prefix = '@' - end - - ruby_version_is "3.0" do - @path_prefix = ' ' - end + @path_prefix = ' ' end it "enables both TracePoints but only calls the respective callbacks" do |