ruby-changes:52128
From: kazu <ko1@a...>
Date: Mon, 13 Aug 2018 21:22:47 +0900 (JST)
Subject: [ruby-changes:52128] kazu:r64336 (trunk): test/rinda/test_rinda.rb: Start keeper only on used tests
kazu 2018-08-13 21:22:43 +0900 (Mon, 13 Aug 2018) New Revision: 64336 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64336 Log: test/rinda/test_rinda.rb: Start keeper only on used tests to reduce sleeping threads on unrelated tests Modified files: trunk/test/rinda/test_rinda.rb Index: test/rinda/test_rinda.rb =================================================================== --- test/rinda/test_rinda.rb (revision 64335) +++ test/rinda/test_rinda.rb (revision 64336) @@ -17,16 +17,36 @@ class MockClock https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L17 def keeper_thread nil end + + def stop_keeper + if @keeper + @keeper.kill + @keeper.join + @keeper = nil + end + end end def initialize @now = 2 @reso = 1 + @ts = nil + @inf = 2**31 - 1 + end + + def start_keeper + @now = 2 + @reso = 1 + @ts&.stop_keeper @ts = MyTS.new @ts.write([2, :now]) @inf = 2**31 - 1 end + def stop_keeper + @ts.stop_keeper + end + def now @now.to_f end @@ -100,6 +120,14 @@ class TupleSpace https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L120 end module TupleSpaceTestModule + def setup + MockClock.instance.start_keeper + end + + def teardown + MockClock.instance.stop_keeper + end + def sleep(n) if Thread.current == Thread.main Time.forward(n) @@ -446,6 +474,7 @@ class TupleSpaceTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L474 include TupleSpaceTestModule def setup + super ThreadGroup.new.add(Thread.current) @ts = Rinda::TupleSpace.new(1) end @@ -457,6 +486,7 @@ class TupleSpaceTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L486 th.join end } + super end end @@ -464,6 +494,7 @@ class TupleSpaceProxyTest < Test::Unit:: https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L494 include TupleSpaceTestModule def setup + super ThreadGroup.new.add(Thread.current) @ts_base = Rinda::TupleSpace.new(1) @ts = Rinda::TupleSpaceProxy.new(@ts_base) @@ -478,6 +509,7 @@ class TupleSpaceProxyTest < Test::Unit:: https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L509 end } @server.stop_service + super end def test_remote_array_and_hash -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/