From 7905fc1e54cda03594f050a76586780cd6968de3 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 14 Jun 2011 04:07:03 +0000 Subject: [PATCH] * test/io/console/test_io_console.rb (TestIO_Console#test_noctty): split for each platforms. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/io/console/test_io_console.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index d48f1532b0..e273a0fe8f 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -168,18 +168,22 @@ end if defined?(PTY) and defined?(IO::console) class TestIO_Console < Test::Unit::TestCase require_relative '../../ruby/envutil' - def test_noctty - if Process.respond_to?(:daemon) + case + when Process.respond_to?(:daemon) + def test_noctty assert_in_out_err(["-rio/console"], "Process.daemon(true, true); p IO.console", ["nil"]) - elsif !(rubyw = RbConfig::CONFIG["RUBYW_INSTALL_NAME"]).empty? - require 'tempfile' + end + when !(rubyw = RbConfig::CONFIG["RUBYW_INSTALL_NAME"]).empty? + require 'tempfile' + dir, base = File.split(EnvUtil.rubybin) + RUBYW = File.join(dir, base.sub(/ruby/, rubyw)) + + def test_noctty t = Tempfile.new("console") t.close - dir, base = File.split(EnvUtil.rubybin) - rubywbin = File.join(dir, base.sub(/ruby/, rubyw)) - cmd = [rubywbin, '-rio/console', '-e', 'STDOUT.reopen(ARGV[0]); p IO.console', '--', t.path] + cmd = [RUBYW, '-rio/console', '-e', 'STDOUT.reopen(ARGV[0]); p IO.console', '--', t.path] system(*cmd) t.open assert_equal("nil", t.gets.chomp)