[前][次][番号順一覧][スレッド一覧]

ruby-changes:63917

From: aycabta <ko1@a...>
Date: Sat, 5 Dec 2020 03:09:08 +0900 (JST)
Subject: [ruby-changes:63917] 62666a6bbd (master): [ruby/reline] Add write_inputrc

https://git.ruby-lang.org/ruby.git/commit/?id=62666a6bbd

From 62666a6bbdab7a066c761283e448132215ca2e7d Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Tue, 6 Oct 2020 23:55:33 +0900
Subject: [ruby/reline] Add write_inputrc

https://github.com/ruby/reline/commit/70536d8c9a

diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 0ab43fa..1c2b04f 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -117,11 +117,9 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L117
     end
 
     def test_prompt
-      File.open(@inputrc_file, 'w') do |f|
-        f.write <<~'LINES'
-          "abc": "123"
-        LINES
-      end
+      write_inputrc <<~'LINES'
+        "abc": "123"
+      LINES
       start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
       sleep 0.5
       write("abc\n")
@@ -135,11 +133,9 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L133
     end
 
     def test_mode_icon_emacs
-      File.open(@inputrc_file, 'w') do |f|
-        f.write <<~LINES
-          set show-mode-in-prompt on
-        LINES
-      end
+      write_inputrc <<~LINES
+        set show-mode-in-prompt on
+      LINES
       start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
       sleep 0.5
       close
@@ -150,12 +146,10 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L146
     end
 
     def test_mode_icon_vi
-      File.open(@inputrc_file, 'w') do |f|
-        f.write <<~LINES
-          set editing-mode vi
-          set show-mode-in-prompt on
-        LINES
-      end
+      write_inputrc <<~LINES
+        set editing-mode vi
+        set show-mode-in-prompt on
+      LINES
       start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
       sleep 0.5
       write(":a\n\C-[k")
@@ -169,12 +163,10 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L163
     end
 
     def test_original_mode_icon_emacs
-      File.open(@inputrc_file, 'w') do |f|
-        f.write <<~LINES
-          set show-mode-in-prompt on
-          set emacs-mode-string [emacs]
-        LINES
-      end
+      write_inputrc <<~LINES
+        set show-mode-in-prompt on
+        set emacs-mode-string [emacs]
+      LINES
       start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
       close
       assert_screen(<<~EOC)
@@ -184,12 +176,10 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L176
     end
 
     def test_original_mode_icon_with_quote
-      File.open(@inputrc_file, 'w') do |f|
-        f.write <<~LINES
-          set show-mode-in-prompt on
-          set emacs-mode-string "[emacs]"
-        LINES
-      end
+      write_inputrc <<~LINES
+        set show-mode-in-prompt on
+        set emacs-mode-string "[emacs]"
+      LINES
       start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
       close
       assert_screen(<<~EOC)
@@ -199,14 +189,12 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L189
     end
 
     def test_original_mode_icon_vi
-      File.open(@inputrc_file, 'w') do |f|
-        f.write <<~LINES
-          set editing-mode vi
-          set show-mode-in-prompt on
-          set vi-ins-mode-string "{InS}"
-          set vi-cmd-mode-string "{CmD}"
-        LINES
-      end
+      write_inputrc <<~LINES
+        set editing-mode vi
+        set show-mode-in-prompt on
+        set vi-ins-mode-string "{InS}"
+        set vi-cmd-mode-string "{CmD}"
+      LINES
       start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl})
       write(":a\n\C-[k")
       close
@@ -217,6 +205,12 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L205
         {CmD}prompt> :a
       EOC
     end
+
+    private def write_inputrc(content)
+      File.open(@inputrc_file, 'w') do |f|
+        f.write content
+      end
+    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/

[前][次][番号順一覧][スレッド一覧]