From 50e41f4a4fc2ba5a001536845b44d52010791237 Mon Sep 17 00:00:00 2001 From: kazu Date: Mon, 13 Aug 2018 12:22:43 +0000 Subject: test/rinda/test_rinda.rb: Start keeper only on used tests to reduce sleeping threads on unrelated tests git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rinda/test_rinda.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/rinda') diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb index c899f32a8a..cde5f22bb6 100644 --- a/test/rinda/test_rinda.rb +++ b/test/rinda/test_rinda.rb @@ -17,16 +17,36 @@ class MockClock 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 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::TestCase include TupleSpaceTestModule def setup + super ThreadGroup.new.add(Thread.current) @ts = Rinda::TupleSpace.new(1) end @@ -457,6 +486,7 @@ class TupleSpaceTest < Test::Unit::TestCase th.join end } + super end end @@ -464,6 +494,7 @@ class TupleSpaceProxyTest < Test::Unit::TestCase 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::TestCase end } @server.stop_service + super end def test_remote_array_and_hash -- cgit v1.2.3