ruby-changes:29374
From: nobu <ko1@a...>
Date: Wed, 19 Jun 2013 16:48:44 +0900 (JST)
Subject: [ruby-changes:29374] nobu:r41426 (trunk): drbtest.rb: DRbBase
nobu 2013-06-19 16:47:38 +0900 (Wed, 19 Jun 2013) New Revision: 41426 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41426 Log: drbtest.rb: DRbBase * test/drb/drbtest.rb (DRbBase): extract from DRbCore and DRbAry for setup_service and teardown. Modified files: trunk/test/drb/drbtest.rb trunk/test/drb/ignore_test_drb.rb trunk/test/drb/test_drb.rb trunk/test/drb/test_drbssl.rb trunk/test/drb/test_drbunix.rb Index: test/drb/test_drbssl.rb =================================================================== --- test/drb/test_drbssl.rb (revision 41425) +++ test/drb/test_drbssl.rb (revision 41426) @@ -36,9 +36,8 @@ end https://github.com/ruby/ruby/blob/trunk/test/drb/test_drbssl.rb#L36 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 https://github.com/ruby/ruby/blob/trunk/test/drb/test_drbssl.rb#L53 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 Index: test/drb/test_drb.rb =================================================================== --- test/drb/test_drb.rb (revision 41425) +++ test/drb/test_drb.rb (revision 41426) @@ -2,16 +2,19 @@ require_relative 'drbtest' https://github.com/ruby/ruby/blob/trunk/test/drb/test_drb.rb#L2 class TestDRbCore < Test::Unit::TestCase include DRbCore -end -class TestDRbYield < Test::Unit::TestCase def setup - @ext = DRbService.ext_service('ut_drb.rb') - @there = @ext.front + setup_service 'ut_drb.rb' + super end +end - def teardown - @ext.stop_service if @ext +class TestDRbYield < Test::Unit::TestCase + include DRbBase + + def setup + setup_service 'ut_drb.rb' + super end def test_01_one @@ -177,12 +180,19 @@ end https://github.com/ruby/ruby/blob/trunk/test/drb/test_drb.rb#L180 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::TestC https://github.com/ruby/ruby/blob/trunk/test/drb/test_drb.rb#L202 @server.each do |s| s.stop_service end - @ext.stop_service if @ext + super end def test_01 @@ -202,9 +212,7 @@ end https://github.com/ruby/ruby/blob/trunk/test/drb/test_drb.rb#L212 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::TestCa https://github.com/ruby/ruby/blob/trunk/test/drb/test_drb.rb#L266 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::TestCas https://github.com/ruby/ruby/blob/trunk/test/drb/test_drb.rb#L308 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 Index: test/drb/drbtest.rb =================================================================== --- test/drb/drbtest.rb (revision 41425) +++ test/drb/drbtest.rb (revision 41426) @@ -63,9 +63,9 @@ class XArray < Array https://github.com/ruby/ruby/blob/trunk/test/drb/drbtest.rb#L63 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 https://github.com/ruby/ruby/blob/trunk/test/drb/drbtest.rb#L94 end } end +end + +module DRbCore + include DRbBase def test_00_DRbObject ro = DRbObject.new(nil, 'druby://localhost:12345') @@ -288,36 +292,7 @@ module DRbCore https://github.com/ruby/ruby/blob/trunk/test/drb/drbtest.rb#L292 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) Index: test/drb/ignore_test_drb.rb =================================================================== --- test/drb/ignore_test_drb.rb (revision 41425) +++ test/drb/ignore_test_drb.rb (revision 41426) @@ -4,21 +4,7 @@ class TestDRbReusePort < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/drb/ignore_test_drb.rb#L4 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 Index: test/drb/test_drbunix.rb =================================================================== --- test/drb/test_drbunix.rb (revision 41425) +++ test/drb/test_drbunix.rb (revision 41426) @@ -20,9 +20,8 @@ end https://github.com/ruby/ruby/blob/trunk/test/drb/test_drbunix.rb#L20 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 https://github.com/ruby/ruby/blob/trunk/test/drb/test_drbunix.rb#L37 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/