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

ruby-changes:51984

From: normal <ko1@a...>
Date: Mon, 6 Aug 2018 05:07:00 +0900 (JST)
Subject: [ruby-changes:51984] normal:r64199 (trunk): test/ruby/test_thread.rb (test_thread_timer_and_interrupt): add timeouts

normal	2018-08-06 05:06:55 +0900 (Mon, 06 Aug 2018)

  New Revision: 64199

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64199

  Log:
    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

  Modified files:
    trunk/test/ruby/test_thread.rb
Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 64198)
+++ test/ruby/test_thread.rb	(revision 64199)
@@ -952,15 +952,16 @@ _eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L952
   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

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

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