mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 14:34:39 +02:00
* 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/trunk@33468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3a0e582e1f
commit
039f12b5bb
3 changed files with 38 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue