diff options
| author | Stan Lo <stan001212@gmail.com> | 2023-08-21 19:23:27 +0100 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-08-21 18:23:32 +0000 |
| commit | ca6db02c2a305bc990c144439996abfe984a6c5a (patch) | |
| tree | 35797e2cee5aea937b4c868a5bb7bcba738a8f8a /test | |
| parent | 7d26c03267cf1be643963355fc52efde1574b37a (diff) | |
[ruby/irb] Avoid overriding user's `irb_name` setting in debugger
integration
(https://github.com/ruby/irb/pull/688)
* Avoid overriding user's irb_name setting in debugger integration
Instead of always setting `irb_name` to `irb:rdbg`, it should respect
the user's setting and only append `:rdbg` to it.
* Introduce write_rc test helper
https://github.com/ruby/irb/commit/2ce7593351
Diffstat (limited to 'test')
| -rw-r--r-- | test/irb/helper.rb | 19 | ||||
| -rw-r--r-- | test/irb/test_debug_cmd.rb | 19 | ||||
| -rw-r--r-- | test/irb/test_history.rb | 5 |
3 files changed, 37 insertions, 6 deletions
diff --git a/test/irb/helper.rb b/test/irb/helper.rb index e281b8e2f6..122eb607f1 100644 --- a/test/irb/helper.rb +++ b/test/irb/helper.rb @@ -83,6 +83,9 @@ module TestIRB TIMEOUT_SEC = 3 def setup + @envs = {} + @tmpfiles = [] + unless defined?(PTY) omit "Integration tests require PTY." end @@ -90,8 +93,12 @@ module TestIRB if ruby_core? omit "This test works only under ruby/irb" end + end - @envs = {} + def teardown + @tmpfiles.each do |tmpfile| + File.unlink(tmpfile) + end end def run_ruby_file(&block) @@ -133,7 +140,6 @@ module TestIRB MSG assert_block(message) { false } ensure - File.unlink(@ruby_file) if @ruby_file FileUtils.remove_entry tmp_dir end @@ -180,8 +186,17 @@ module TestIRB def write_ruby(program) @ruby_file = Tempfile.create(%w{irb- .rb}) + @tmpfiles << @ruby_file @ruby_file.write(program) @ruby_file.close end + + def write_rc(content) + @irbrc = Tempfile.new('irbrc') + @tmpfiles << @irbrc + @irbrc.write(content) + @irbrc.close + @envs['IRBRC'] = @irbrc.path + end end end diff --git a/test/irb/test_debug_cmd.rb b/test/irb/test_debug_cmd.rb index c4e4a04fdd..a99f7a943f 100644 --- a/test/irb/test_debug_cmd.rb +++ b/test/irb/test_debug_cmd.rb @@ -289,6 +289,25 @@ module TestIRB assert_match(/irb:rdbg\(main\):005> next/, output) end + def test_prompt_irb_name_is_kept + write_rc <<~RUBY + IRB.conf[:IRB_NAME] = "foo" + RUBY + + write_ruby <<~'ruby' + binding.irb + puts "Hello" + ruby + + output = run_ruby_file do + type "next" + type "continue" + end + + assert_match(/foo\(main\):001> next/, output) + assert_match(/foo:rdbg\(main\):002> continue/, output) + end + def test_irb_commands_are_available_after_moving_around_with_the_debugger write_ruby <<~'ruby' class Foo diff --git a/test/irb/test_history.rb b/test/irb/test_history.rb index 9bf146609c..15628e66e2 100644 --- a/test/irb/test_history.rb +++ b/test/irb/test_history.rb @@ -326,12 +326,9 @@ module TestIRB @history_file = Tempfile.new('irb_history') @history_file.write(history) @history_file.close - @irbrc = Tempfile.new('irbrc') - @irbrc.write <<~RUBY + write_rc <<~RUBY IRB.conf[:HISTORY_FILE] = "#{@history_file.path}" RUBY - @irbrc.close - @envs['IRBRC'] = @irbrc.path end end end |
