[前][次][番号順一覧][スレッド一覧]

ruby-changes:9195

From: akr <ko1@a...>
Date: Sun, 14 Dec 2008 12:52:23 +0900 (JST)
Subject: [ruby-changes:9195] Ruby:r20732 (trunk): new file.

akr	2008-12-14 12:52:13 +0900 (Sun, 14 Dec 2008)

  New Revision: 20732

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20732

  Log:
    new file.

  Added files:
    trunk/test/test_pty.rb

Index: test/test_pty.rb
===================================================================
--- test/test_pty.rb	(revision 0)
+++ test/test_pty.rb	(revision 20732)
@@ -0,0 +1,46 @@
+require 'test/unit'
+require_relative 'ruby/envutil'
+require 'shellwords'
+
+begin
+  require 'pty'
+rescue LoadError
+end
+
+class TestPTY < Test::Unit::TestCase
+  RUBY = EnvUtil.rubybin
+
+  def test_spawn_without_block
+    r, w, pid = PTY.spawn(RUBY, '-e', 'puts "a"')
+    assert_equal("a\r\n", r.gets)
+    assert_raise(Errno::EIO) { r.gets }
+  ensure
+    Process.wait pid if pid
+  end
+
+  def test_spawn_with_block
+    PTY.spawn(RUBY, '-e', 'puts "b"') {|r,w,pid|
+      assert_equal("b\r\n", r.gets)
+      Process.wait(pid)
+      assert_raise(Errno::EIO) { r.gets }
+    }
+  end
+
+  def test_commandline
+    commandline = Shellwords.join([RUBY, '-e', 'puts "foo"'])
+    PTY.spawn(commandline) {|r,w,pid|
+      assert_equal("foo\r\n", r.gets)
+      Process.wait(pid)
+      assert_raise(Errno::EIO) { r.gets }
+    }
+  end
+
+  def test_argv0
+    PTY.spawn([RUBY, "argv0"], '-e', 'puts "bar"') {|r,w,pid|
+      assert_equal("bar\r\n", r.gets)
+      Process.wait(pid)
+      assert_raise(Errno::EIO) { r.gets }
+    }
+  end
+end if defined? PTY
+

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]