From 1e51f3046301c41e23b51aa75aa205dd14a440c0 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 28 Apr 2013 03:54:26 +0000 Subject: [PATCH] test_io_console.rb: investigate hang-up * test/io/console/test_io_console.rb (TestIO_Console#test_noctty): grab error outputs and stop the loop upto 3 seconds. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/io/console/test_io_console.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index 65514f2b81..a9de376a2b 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -264,14 +264,22 @@ class TestIO_Console < Test::Unit::TestCase t2.close cmd = NOCTTY + [ '--disable=gems', - '-rio/console', - '-e', 'open(ARGV[0], "w") {|f| f.puts IO.console.inspect}', - '-e', 'File.unlink(ARGV[1])', + '-e', 'open(ARGV[0], "w") {|f|', + '-e', 'STDOUT.reopen(f)', + '-e', 'STDERR.reopen(f)', + '-e', 'require "io/console"', + '-e', 'f.puts IO.console.inspect', + '-e', 'f.flush', + '-e', 'File.unlink(ARGV[1])', + '-e', '}', '--', t.path, t2.path] system(*cmd) - sleep 0.1 while File.exist?(t2.path) + 30.times do + break unless File.exist?(t2.path) + sleep 0.1 + end t.open - assert_equal("nil", t.gets.chomp) + assert_equal("nil", t.gets(nil).chomp) ensure t.close! if t and !t.closed? t2.close!