ruby-changes:62620
From: aycabta <ko1@a...>
Date: Tue, 18 Aug 2020 19:16:03 +0900 (JST)
Subject: [ruby-changes:62620] 0bc748db36 (master): [ruby/reline] Call #start_terminal after generating temporary inputrc
https://git.ruby-lang.org/ruby.git/commit/?id=0bc748db36 From 0bc748db3685d867f54a4e1b589b732608a1ca69 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Sun, 12 Jul 2020 23:29:45 +0900 Subject: [ruby/reline] Call #start_terminal after generating temporary inputrc because inputrc will be read when starting up https://github.com/ruby/reline/commit/0a30464385 diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index 329fce4..080bc36 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -6,7 +6,7 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L6 class Reline::TestRendering < Yamatanooroti::TestCase def setup @pwd = Dir.pwd - @tmpdir = File.join(Dir.tmpdir, "test_reline_config_#{$$}") + @tmpdir = File.join(File.expand_path(Dir.tmpdir), "test_reline_config_#{$$}") begin Dir.mkdir(@tmpdir) rescue Errno::EEXIST @@ -14,20 +14,20 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L14 Dir.mkdir(@tmpdir) end Dir.chdir(@tmpdir) - inputrc_backup = ENV['INPUTRC'] - @inputrc_file = ENV['INPUTRC'] = File.expand_path('temporaty_inputrc') + @inputrc_backup = ENV['INPUTRC'] + @inputrc_file = ENV['INPUTRC'] = File.join(@tmpdir, 'temporaty_inputrc') File.unlink(@inputrc_file) if File.exist?(@inputrc_file) - start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}) - sleep 0.5 - ENV['INPUTRC'] = inputrc_backup end def teardown Dir.chdir(@pwd) FileUtils.rm_rf(@tmpdir) + ENV['INPUTRC'] = @inputrc_backup end def test_history_back + start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}) + sleep 0.5 write(":a\n") write("\C-p") close @@ -40,6 +40,8 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L40 end def test_backspace + start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}) + sleep 0.5 write(":abc\C-h\n") close assert_screen(<<~EOC) @@ -51,6 +53,8 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L53 end def test_autowrap + start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}) + sleep 0.5 write('01234567890123456789012') close assert_screen(<<~EOC) @@ -59,6 +63,24 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L63 2 EOC end + + def test_prompt + File.open(@inputrc_file, 'w') do |f| + f.write <<~'LINES' + "abc": "123" + LINES + end + start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}) + sleep 0.5 + write("abc\n") + close + assert_screen(<<~EOC) + Multiline REPL. + prompt> 123 + => 123 + prompt> + EOC + end end rescue LoadError, NameError # On Ruby repository, this test suit doesn't run because Ruby repo doesn't -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/