Skip to content
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

Use stricter check to skip prelude.rb #867

Merged
merged 2 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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