From 1f7eb6e7aed27b1618adf2b443be93c8eab1a395 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 29 Jun 2010 22:29:12 +0000 Subject: * test/ruby/test_rubyoptions.rb (test_script_from_stdin): by using a pipe, get rid of not-well-defined behavior after the child process terminated in pty. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_rubyoptions.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'test/ruby/test_rubyoptions.rb') diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index faa7c5a9df..e41bdf2936 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -431,18 +431,25 @@ class TestRubyOptions < Test::Unit::TestCase end require 'timeout' result = nil - PTY.spawn(EnvUtil.rubybin) do |s, m| + s, w = IO.pipe + PTY.spawn(EnvUtil.rubybin, out: w) do |r, m| + w.close m.print("\C-d") assert_nothing_raised('[ruby-dev:37798]') do - Timeout.timeout(3) {s.read} + result = Timeout.timeout(3) {s.read} end end - PTY.spawn(EnvUtil.rubybin) do |s, m| + s.close + assert_equal("", result, '[ruby-dev:37798]') + s, w = IO.pipe + PTY.spawn(EnvUtil.rubybin, out: w) do |r, m| + w.close m.print("$stdin.read; p $stdin.gets\n\C-d") m.print("abc\n\C-d") m.print("zzz\n") result = s.read end - assert_match(/zzz\r\n"zzz\\n"\r\n\z/, result, '[ruby-core:30910]') + s.close + assert_equal("\"zzz\\n\"\n", result, '[ruby-core:30910]') end end -- cgit v1.2.3