summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortomoya ishida <tomoyapenguin@gmail.com>2024-04-05 01:38:41 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2024-04-05 09:34:28 +0900
commit4e48d2724edafdebfe7fba4db01a50cd2a726d20 (patch)
treee5218642e844ad49bf154d0740148b68414e4652 /test
parent4cbe4e49c7e2a90d7d34337343187ab9af2f58d1 (diff)
[ruby/reline] Thread safe readline
(https://github.com/ruby/reline/pull/669) Block until other Reline.readline or Reline.readmultiline finish https://github.com/ruby/reline/commit/ebab2875f1
Diffstat (limited to 'test')
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 3409b8905c..fe0f8842ea 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -1690,6 +1690,23 @@ begin
EOC
end
+ def test_thread_safe
+ start_terminal(6, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --auto-indent}, startup_message: 'Multiline REPL.')
+ write("[Thread.new{Reline.readline'>'},Thread.new{Reline.readmultiline('>'){true}}].map(&:join).size\n")
+ write("exit\n")
+ write("exit\n")
+ write("42\n")
+ close
+ assert_screen(<<~EOC)
+ >exit
+ >exit
+ => 2
+ prompt> 42
+ => 42
+ prompt>
+ EOC
+ end
+
def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content