Skip to content

Commit

Permalink
Use stricter check to skip prelude loading
Browse files Browse the repository at this point in the history
Cherry-picked from ruby#867
  • Loading branch information
st0012 committed Dec 21, 2022
1 parent 6f4aa3e commit c951d3b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/debug/prelude.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

return if ENV['RUBY_DEBUG_ENABLE'] == '0'
return if defined?(::DEBUGGER__)
return if defined?(::DEBUGGER__::Session)

# Put the following line in your login script (e.g. ~/.bash_profile) with modified path:
#
Expand Down
41 changes: 41 additions & 0 deletions test/console/debugger_method_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,45 @@ def test_step_in_stops_the_program
end
end
end

class PreludeTest < ConsoleTestCase
def program
<<~RUBY
1| require "debug/prelude"
2| debugger_source = Kernel.method(:debugger).source_location
3| a = 100
4| b = 20
5| debugger
6|
7| __END__
RUBY
end

def test_prelude_defines_debugger_statements
run_ruby(program, options: "-Ilib") do
assert_line_num(5)
type "a + b"
assert_line_text(/120/)
type "c"
end
end

def test_prelude_doesnt_override_debugger
run_ruby(program, options: "-Ilib -rdebug") do
assert_line_num(5)
type "debugger_source"
assert_line_text(/debug\/session\.rb/)
type "c"
end
end

def test_require_config_doesnt_cancel_prelude
run_ruby(program, options: "-Ilib -rdebug/config") do
assert_line_num(5)
type "a + b"
assert_line_text(/120/)
type "c"
end
end
end
end

0 comments on commit c951d3b

Please sign in to comment.