diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-03 01:00:23 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-03 01:00:23 +0000 |
commit | 6bdde0e5e612befe47c0a4e87f4900dbb106f78e (patch) | |
tree | 57a32461394f61f9442dccb1f052d141efd5a99e /test/test_pty.rb | |
parent | 9e736114eb489293a3708d04efed3cb492de6f92 (diff) |
merge revision(s) 33468:
* ext/pty/pty.c (pty_check): should return nil until the child
terminates or stops. [ruby-dev:44600] [Bug #2642]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_pty.rb')
-rw-r--r-- | test/test_pty.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_pty.rb b/test/test_pty.rb index fc8cd95c8b..025cafc8f8 100644 --- a/test/test_pty.rb +++ b/test/test_pty.rb @@ -163,5 +163,37 @@ class TestPTY < Test::Unit::TestCase } end end + + def test_pty_check_default + st1 = st2 = pid = nil + `echo` # preset $? + PTY.spawn("cat") do |r,w,id| + pid = id + st1 = PTY.check(pid) + w.close + r.close + sleep(0.1) + st2 = PTY.check(pid) + end + assert_equal(pid, st1.pid) if st1 + assert_nil(st1) + assert_equal(pid, st2.pid) + end + + def test_pty_check_raise + bug2642 = '[ruby-dev:44600]' + st1 = st2 = pid = nil + PTY.spawn("cat") do |r,w,id| + pid = id + assert_nothing_raised(PTY::ChildExited, bug2642) {st1 = PTY.check(pid, true)} + w.close + r.close + sleep(0.1) + st2 = assert_raise(PTY::ChildExited, bug2642) {PTY.check(pid, true)}.status + end + assert_equal(pid, st1.pid) if st1 + assert_nil(st1) + assert_equal(pid, st2.pid) + end end if defined? PTY |