summaryrefslogtreecommitdiff
path: root/test/rinda
diff options
context:
space:
mode:
authorkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-13 12:22:43 +0000
committerkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-13 12:22:43 +0000
commit50e41f4a4fc2ba5a001536845b44d52010791237 (patch)
tree189a3e8ef07146f8df960e5b1914d53c34e6db7e /test/rinda
parent0ab6266c9d5381b774e3d6d310dd7b43196cef0a (diff)
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
Diffstat (limited to 'test/rinda')
-rw-r--r--test/rinda/test_rinda.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index c899f32a8ab..cde5f22bb69 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