-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix usage of tracer gem and add tests #857
Conversation
# Loading the gem "tracer" will cause it to extend IRB commands with: | ||
# https://github.com/ruby/tracer/blob/v0.2.2/lib/tracer/irb.rb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me some time to figure this out. Is this helpful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added that because IRB currently doesn't have integration with it. Do you think dropping it will make things easier here?
Tracer.verbose = false | ||
Tracer.add_filter { | ||
|event, file, line, id, binding, *rests| | ||
/^#{Regexp.quote(@CONF[:IRB_LIB_PATH])}/ !~ file and | ||
File::basename(file) != "irb.rb" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracer.verbose
and Tracer.add_filter
were available in v0.1.x and I could not find an equivalent in the 0.2.x API.
if opt | ||
Tracer.set_get_line_procs(@irb_path) { | ||
|line_no, *rests| | ||
@io.line(line_no) | ||
} | ||
elsif !opt && @use_tracer | ||
Tracer.off | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, set_get_line_procs
, off
/ on
are all method of the v0.1.x API, without an equivalent in v0.2.x
0b4c703
to
4afb6bd
Compare
Rebased. |
Hmm, just before the rebase we were all green: https://github.com/ruby/irb/actions/runs/7758254084 Is there a way to retry? The current error does not seem related. |
The new tests are skipped when ruby below 3.1, as it was a default gem on it, and in a version we do not support. This also move definition of `use_tracer` to module Context instead of monkey patch.
ff5cfb5
to
b658e7c
Compare
Updated with feedback and rebased. |
I've tested this PR and it works great, thanks! One observation, and I am not sure if it's even possible, would be to strip off the calls from
|
The older version of Tracer supported The current version of tracer only supports an inclusive pattern as far as I can tell: https://github.com/ruby/tracer/blob/dc71573705638463ea2c50f5e9ff10dd275dc193/lib/tracer/base.rb#L78 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
I think some polishing can still be made, but I'll that in a follow up PR 👍
(ruby/irb#857) The new tests are skipped when ruby below 3.1, as it was a default gem on it, and in a version we do not support. This also move definition of `use_tracer` to module Context instead of monkey patch. ruby/irb@08834fbd5f
Fixes support of option
--tracer
whengem tracer >= 0.2.0
is installed.The API for tracer changed a lot from 0.1.x to 0.2.x. For reference, here is the old API: https://github.com/ruby/tracer/blob/v0.1.1/lib/tracer.rb
This PR also adds some tests for this integration:
WITH_TRACER=true bundle exec rake test
The new tests are executed. There is one test that verifies behaviour when
--tracer
is set, but gem is not bundled:Skipping test_use_tracer_when_gem_is_unavailable because 'tracer' gem is available.
WITH_TRACER=false bundle exec rake test
The new tests will be skipped with message
Skipping ContextWithTracerTest because 'tracer' gem is not available. Enable with WITH_TRACER=true.
Closes #752
Closes #694