Permalink
Browse files

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
  • Loading branch information...
znz committed Aug 13, 2018
1 parent 0ab6266 commit 50e41f4a4fc2ba5a001536845b44d52010791237
Showing with 32 additions and 0 deletions.
  1. +32 −0 test/rinda/test_rinda.rb
@@ -17,16 +17,36 @@ class MyTS < Rinda::TupleSpace
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 @@ def sleep(n)
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,13 +486,15 @@ def teardown
th.join
end
}
super
end
end
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 @@ def teardown
end
}
@server.stop_service
super
end
def test_remote_array_and_hash

0 comments on commit 50e41f4

Please sign in to comment.