Repository navigation
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.
It took me some time to figure this out. Is this helpful?
There was a problem hiding this comment.
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.
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.
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 |
st0012
left a comment
There was a problem hiding this comment.
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
--tracerwhengem tracer >= 0.2.0is 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 testThe new tests are executed. There is one test that verifies behaviour when
--traceris 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 testThe new tests will be skipped with message
Skipping ContextWithTracerTest because 'tracer' gem is not available. Enable with WITH_TRACER=true.Closes #752
Closes #694