diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-05 20:06:55 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-05 20:06:55 +0000 |
commit | 9f395f11202fc3c7edbd76f5aa6ce1f8a1e752a9 (patch) | |
tree | 63d3d2ba78e5b5e55ae710459f7230c7df365530 /test | |
parent | d17c7ba35277231a3c6d38a955c23f530f039cb4 (diff) | |
download | ruby-9f395f11202fc3c7edbd76f5aa6ce1f8a1e752a9.tar.gz |
test/ruby/test_thread.rb (test_thread_timer_and_interrupt): add timeouts
Trying to diagnose CI failures from i686-linux on Debian 7.
This also fixes a potential GC problem with Thread.start or
IO#read potentially closing the write-end of the pipe due
to allocation.
cf. http://www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20180805T080500Z.fail.html.gz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_thread.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 03fd1e3075..56a7bfb23b 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -952,15 +952,16 @@ _eom def test_thread_timer_and_interrupt bug5757 = '[ruby-dev:44985]' pid = nil - cmd = 'Signal.trap(:INT, "DEFAULT"); r,=IO.pipe; Thread.start {Thread.pass until Thread.main.stop?; puts; STDOUT.flush}; r.read' + cmd = 'Signal.trap(:INT, "DEFAULT"); pipe=IO.pipe; Thread.start {Thread.pass until Thread.main.stop?; puts; STDOUT.flush}; pipe[0].read' opt = {} opt[:new_pgroup] = true if /mswin|mingw/ =~ RUBY_PLATFORM s, t, _err = EnvUtil.invoke_ruby(['-e', cmd], "", true, true, opt) do |in_p, out_p, err_p, cpid| + assert IO.select([out_p], nil, nil, 10), 'subprocess not ready' out_p.gets pid = cpid t0 = Time.now.to_f Process.kill(:SIGINT, pid) - Process.wait(pid) + Timeout.timeout(10) { Process.wait(pid) } t1 = Time.now.to_f [$?, t1 - t0, err_p.read] end |