mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
drbtest.rb: DRbBase
* test/drb/drbtest.rb (DRbBase): extract from DRbCore and DRbAry for setup_service and teardown. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
226fcd5814
commit
b0f623f5f4
5 changed files with 45 additions and 84 deletions
|
@ -63,9 +63,9 @@ class XArray < Array
|
|||
end
|
||||
end
|
||||
|
||||
module DRbCore
|
||||
def setup
|
||||
@service_name = 'ut_drb.rb'
|
||||
module DRbBase
|
||||
def setup_service(service_name)
|
||||
@service_name = service_name
|
||||
@ext = DRbService.ext_service(@service_name)
|
||||
@there = @ext.front
|
||||
end
|
||||
|
@ -94,6 +94,10 @@ module DRbCore
|
|||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
module DRbCore
|
||||
include DRbBase
|
||||
|
||||
def test_00_DRbObject
|
||||
ro = DRbObject.new(nil, 'druby://localhost:12345')
|
||||
|
@ -288,36 +292,7 @@ module DRbCore
|
|||
end
|
||||
|
||||
module DRbAry
|
||||
def setup
|
||||
@service_name = 'ut_array.rb'
|
||||
@ext = DRbService.ext_service(@service_name)
|
||||
@there = @ext.front
|
||||
end
|
||||
|
||||
def teardown
|
||||
@ext.stop_service if defined?(@ext) && @ext
|
||||
DRbService.manager.unregist(@service_name)
|
||||
while (@there&&@there.to_s rescue nil)
|
||||
# nop
|
||||
end
|
||||
signal = /mswin|mingw/ =~ RUBY_PLATFORM ? :KILL : :TERM
|
||||
Thread.list.each {|th|
|
||||
if th.respond_to?(:pid) && th[:drb_service] == @service_name
|
||||
10.times do
|
||||
begin
|
||||
Process.kill signal, th.pid
|
||||
break
|
||||
rescue Errno::ESRCH
|
||||
break
|
||||
rescue Errno::EPERM # on Windows
|
||||
sleep 0.1
|
||||
retry
|
||||
end
|
||||
end
|
||||
th.join
|
||||
end
|
||||
}
|
||||
end
|
||||
include DRbBase
|
||||
|
||||
def test_01
|
||||
assert_kind_of(DRb::DRbObject, @there)
|
||||
|
|
|
@ -4,21 +4,7 @@ class TestDRbReusePort < Test::Unit::TestCase
|
|||
include DRbAry
|
||||
|
||||
def setup
|
||||
@ext = DRbService.ext_service('ut_port.rb')
|
||||
@there = @ext.front
|
||||
end
|
||||
|
||||
def teardown
|
||||
return unless @ext
|
||||
@ext.stop_service
|
||||
while true
|
||||
sleep 0.1
|
||||
begin
|
||||
@ext.alive?
|
||||
rescue DRb::DRbConnError
|
||||
break
|
||||
end
|
||||
end
|
||||
setup_service 'ut_port.rb'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,16 +2,19 @@ require_relative 'drbtest'
|
|||
|
||||
class TestDRbCore < Test::Unit::TestCase
|
||||
include DRbCore
|
||||
|
||||
def setup
|
||||
setup_service 'ut_drb.rb'
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
class TestDRbYield < Test::Unit::TestCase
|
||||
def setup
|
||||
@ext = DRbService.ext_service('ut_drb.rb')
|
||||
@there = @ext.front
|
||||
end
|
||||
include DRbBase
|
||||
|
||||
def teardown
|
||||
@ext.stop_service if @ext
|
||||
def setup
|
||||
setup_service 'ut_drb.rb'
|
||||
super
|
||||
end
|
||||
|
||||
def test_01_one
|
||||
|
@ -177,12 +180,19 @@ end
|
|||
|
||||
class TestDRbAry < Test::Unit::TestCase
|
||||
include DRbAry
|
||||
|
||||
def setup
|
||||
setup_service 'ut_array.rb'
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
class TestDRbMServer < Test::Unit::TestCase
|
||||
include DRbBase
|
||||
|
||||
def setup
|
||||
@ext = DRbService.ext_service('ut_drb.rb')
|
||||
@there = @ext.front
|
||||
setup_service 'ut_drb.rb'
|
||||
super
|
||||
@server = (1..3).collect do |n|
|
||||
DRb::DRbServer.new(nil, Onecky.new(n.to_s))
|
||||
end
|
||||
|
@ -192,7 +202,7 @@ class TestDRbMServer < Test::Unit::TestCase
|
|||
@server.each do |s|
|
||||
s.stop_service
|
||||
end
|
||||
@ext.stop_service if @ext
|
||||
super
|
||||
end
|
||||
|
||||
def test_01
|
||||
|
@ -202,9 +212,7 @@ end
|
|||
|
||||
class TestDRbSafe1 < TestDRbAry
|
||||
def setup
|
||||
@service_name = 'ut_safe1.rb'
|
||||
@ext = DRbService.ext_service(@service_name)
|
||||
@there = @ext.front
|
||||
setup_service 'ut_safe1.rb'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -258,13 +266,11 @@ class TestDRbEval # < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
class TestDRbLarge < Test::Unit::TestCase
|
||||
def setup
|
||||
@ext = DRbService.ext_service('ut_large.rb')
|
||||
@there = @ext.front
|
||||
end
|
||||
include DRbBase
|
||||
|
||||
def teardown
|
||||
@ext.stop_service if @ext
|
||||
def setup
|
||||
setup_service 'ut_large.rb'
|
||||
super
|
||||
end
|
||||
|
||||
def test_01_large_ary
|
||||
|
@ -302,13 +308,11 @@ class TestDRbLarge < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
class TestBug4409 < Test::Unit::TestCase
|
||||
def setup
|
||||
@ext = DRbService.ext_service('ut_eq.rb')
|
||||
@there = @ext.front
|
||||
end
|
||||
include DRbBase
|
||||
|
||||
def teardown
|
||||
@ext.stop_service if @ext
|
||||
def setup
|
||||
setup_service 'ut_eq.rb'
|
||||
super
|
||||
end
|
||||
|
||||
def test_bug4409
|
||||
|
|
|
@ -36,9 +36,8 @@ end
|
|||
class TestDRbSSLCore < Test::Unit::TestCase
|
||||
include DRbCore
|
||||
def setup
|
||||
@service_name = 'ut_drb_drbssl.rb'
|
||||
@ext = DRbSSLService.ext_service(@service_name)
|
||||
@there = @ext.front
|
||||
setup_service 'ut_drb_drbssl.rb'
|
||||
super
|
||||
end
|
||||
|
||||
def test_02_unknown
|
||||
|
@ -54,9 +53,8 @@ end
|
|||
class TestDRbSSLAry < Test::Unit::TestCase
|
||||
include DRbAry
|
||||
def setup
|
||||
@service_name = 'ut_array_drbssl.rb'
|
||||
@ext = DRbSSLService.ext_service(@service_name)
|
||||
@there = @ext.front
|
||||
setup_service 'ut_array_drbssl.rb'
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,9 +20,8 @@ end
|
|||
class TestDRbUNIXCore < Test::Unit::TestCase
|
||||
include DRbCore
|
||||
def setup
|
||||
@service_name = 'ut_drb_drbunix.rb'
|
||||
@ext = DRbUNIXService.ext_service(@service_name)
|
||||
@there = @ext.front
|
||||
setup_service 'ut_drb_drbunix.rb'
|
||||
super
|
||||
end
|
||||
|
||||
def test_02_unknown
|
||||
|
@ -38,9 +37,8 @@ end
|
|||
class TestDRbUNIXAry < Test::Unit::TestCase
|
||||
include DRbAry
|
||||
def setup
|
||||
@service_name = 'ut_array_drbunix.rb'
|
||||
@ext = DRbUNIXService.ext_service(@service_name)
|
||||
@there = @ext.front
|
||||
setup_service 'ut_array_drbunix.rb'
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue