[Feature #16513] TracePoint#inspect returns "... file:line" #3391
Conversation
Seems nice. |
I'm not him, but rubyspec parts LGTM |
thread.join | ||
end | ||
|
||
inspect.should == "#<TracePoint:thread_end #{thread_inspection}>" |
eregon
Aug 5, 2020
Member
As the CI shows: https://travis-ci.org/github/ruby/ruby/jobs/715089657
The specs need to pass on older versions of Ruby too.
So you need to use ruby_version_is ""..."2.8" do
and ruby_version_is "2.8" do
guards.
I think a convenient way in this case is to define a local variable at the top of the file (or an @ivar
in a before
block) like:
sep = "@"
ruby_version_is "2.8" do
sep = " "
end
and use it in the expected result.
it 'returns a String showing the event and thread for :thread_begin event' do | ||
inspect = nil | ||
thread_inspection = nil | ||
TracePoint.new(:thread_begin) { |tp| |
eregon
Aug 5, 2020
Member
Can you use a check similar to next unless TracePointSpec.target_thread?
but for thread
here?
Otherwise the TracePoint might catch other Threads which is unwanted as it would fail the spec randomly.
I'm thinking
thread = nil
TracePoint.new(:thread_begin) { |tp|
next unless Thread.current == thread
it 'returns a String showing the event and thread for :thread_end event' do | ||
inspect = nil | ||
thread_inspection = nil | ||
TracePoint.new(:thread_end) { |tp| |
It looks like all the checks are green now. Thanks for your detailed reviews and great suggestions @eregon |
This PR is to resolve ticket https://bugs.ruby-lang.org/issues/16513, so that
TracePoint#inspect
returnspath:line
without@
prefix. This change ensures the consistency with previous changes in https://bugs.ruby-lang.org/issues/16412 and https://bugs.ruby-lang.org/issues/16412.Before
After