* test/ruby/test_process.rb: handshake by pipe instead of sleep.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-12-14 22:34:43 +00:00
Родитель 23201ab1c4
Коммит b46441824f
1 изменённых файлов: 18 добавлений и 7 удалений

Просмотреть файл

@ -1186,10 +1186,14 @@ class TestProcess < Test::Unit::TestCase
return unless Signal.list.include?("QUIT")
with_tmpchdir do
write_file("foo", "sleep 30")
pid = spawn(RUBY, "foo")
Thread.new { sleep 1; Process.kill(:SIGQUIT, pid) }
write_file("foo", "puts;STDOUT.flush;sleep 30")
pid = nil
IO.pipe do |r, w|
pid = spawn(RUBY, "foo", out: w)
w.close
Thread.new { r.read(1); Process.kill(:SIGQUIT, pid) }
Process.wait(pid)
end
t = Time.now
s = $?
assert_equal([false, true, false],
@ -1336,10 +1340,17 @@ class TestProcess < Test::Unit::TestCase
end
signal_received = []
Signal.trap(:CHLD) { signal_received << true }
pid = fork { sleep 0.1; exit }
pid = nil
IO.pipe do |r, w|
pid = fork { r.read(1); exit }
Thread.start { raise }
w.puts
end
Process.wait pid
sleep 0.1
10.times do
break unless signal_received.empty?
sleep 0.01
end
assert_equal [true], signal_received, " [ruby-core:19744]"
rescue NotImplementedError, ArgumentError
ensure