summaryrefslogtreecommitdiff
path: root/test/io/console/test_io_console.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-13 17:23:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-13 17:23:18 +0000
commitd4eae546c87569d93908a4358f0ae85f630b8608 (patch)
treea32bdf5a27380550d7cc4bd0dcdfb388e70b7e9c /test/io/console/test_io_console.rb
parent1d147fb24ca9c76c93c9bc449909364ac9a13b30 (diff)
* test/io/console/test_io_console.rb (TestIO_Console#test_noctty):
fix for Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/io/console/test_io_console.rb')
-rw-r--r--test/io/console/test_io_console.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index b06b5d5c67..d48f1532b0 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -1,7 +1,7 @@
begin
require 'io/console'
- require 'pty'
require 'test/unit'
+ require 'pty'
rescue LoadError
end
@@ -169,8 +169,20 @@ class TestIO_Console < Test::Unit::TestCase
require_relative '../../ruby/envutil'
def test_noctty
- assert_in_out_err(["-rio/console"],
- "Process.daemon(true, true); p IO.console",
- ["nil"])
+ if Process.respond_to?(:daemon)
+ assert_in_out_err(["-rio/console"],
+ "Process.daemon(true, true); p IO.console",
+ ["nil"])
+ elsif !(rubyw = RbConfig::CONFIG["RUBYW_INSTALL_NAME"]).empty?
+ require 'tempfile'
+ 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]
+ system(*cmd)
+ t.open
+ assert_equal("nil", t.gets.chomp)
+ end
end
-end if defined?(Process.daemon) and defined?(IO::console)
+end if defined?(IO.console)