From 5cd71131b849db00f94c87dc6fcf403731338161 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 1 Jun 2014 03:07:58 +0000 Subject: [PATCH] * test/drb: Wrap tests definitions by DRbTests module. This makes several tests (ACLEntryTest, TestBug4409, etc.) easier to understand that they are tests for DRb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/drb/drbtest.rb | 8 ++++++-- test/drb/ignore_test_drb.rb | 3 +++ test/drb/test_acl.rb | 4 +++- test/drb/test_drb.rb | 4 ++++ test/drb/test_drbssl.rb | 4 ++++ test/drb/test_drbunix.rb | 4 ++++ test/drb/ut_array_drbssl.rb | 10 +++++++--- test/drb/ut_drb.rb | 6 +++++- test/drb/ut_drb_drbssl.rb | 12 ++++++++---- test/drb/ut_drb_drbunix.rb | 2 +- test/drb/ut_eq.rb | 7 ++++++- test/drb/ut_eval.rb | 6 +++++- test/drb/ut_large.rb | 6 +++++- test/drb/ut_timerholder.rb | 8 ++++++-- 15 files changed, 73 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 318ee9a9f0..fda1138278 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Jun 1 12:05:10 2014 Tanaka Akira + + * test/drb: Wrap tests definitions by DRbTests module. This makes + several tests (ACLEntryTest, TestBug4409, etc.) easier to understand + that they are tests for DRb. + Sun Jun 1 11:36:25 2014 Tanaka Akira * lib/rinda/ring.rb (RingFinger#make_socket): Close the socket on diff --git a/test/drb/drbtest.rb b/test/drb/drbtest.rb index d0e859d56a..28ad288478 100644 --- a/test/drb/drbtest.rb +++ b/test/drb/drbtest.rb @@ -5,6 +5,8 @@ require 'timeout' require 'shellwords' require_relative '../ruby/envutil' +module DRbTests + class DRbService @@manager = DRb::ExtServManager.new @@ruby = Shellwords.escape(EnvUtil.rubybin) @@ -138,11 +140,11 @@ module DRbCore def test_02_unknown obj = @there.unknown_class assert_kind_of(DRb::DRbUnknown, obj) - assert_equal('Unknown2', obj.name) + assert_equal('DRbTests::Unknown2', obj.name) obj = @there.unknown_module assert_kind_of(DRb::DRbUnknown, obj) - assert_equal('DRbEx::', obj.name) + assert_equal('DRbTests::DRbEx::', obj.name) assert_raise(DRb::DRbUnknownError) do @there.unknown_error @@ -364,3 +366,5 @@ module DRbAry EOS end + +end diff --git a/test/drb/ignore_test_drb.rb b/test/drb/ignore_test_drb.rb index 217c1c3f6b..8b94650534 100644 --- a/test/drb/ignore_test_drb.rb +++ b/test/drb/ignore_test_drb.rb @@ -1,5 +1,7 @@ require 'drbtest' +module DRbTests + class TestDRbReusePort < Test::Unit::TestCase include DRbAry @@ -8,3 +10,4 @@ class TestDRbReusePort < Test::Unit::TestCase end end +end diff --git a/test/drb/test_acl.rb b/test/drb/test_acl.rb index 7fe30f4c4a..a1ee1d48c5 100644 --- a/test/drb/test_acl.rb +++ b/test/drb/test_acl.rb @@ -7,6 +7,8 @@ require 'test/unit' require 'drb/acl' +module DRbTests + class SampleHosts def initialize list = %w(127.0.0.1 localhost @@ -192,4 +194,4 @@ class ACLTest < Test::Unit::TestCase end end - +end diff --git a/test/drb/test_drb.rb b/test/drb/test_drb.rb index 573818558a..7df9ba52c2 100644 --- a/test/drb/test_drb.rb +++ b/test/drb/test_drb.rb @@ -1,5 +1,7 @@ require_relative 'drbtest' +module DRbTests + class TestDRbCore < Test::Unit::TestCase include DRbCore @@ -320,3 +322,5 @@ class TestBug4409 < Test::Unit::TestCase assert(@there.foo?(foo)) end end + +end diff --git a/test/drb/test_drbssl.rb b/test/drb/test_drbssl.rb index a54e2234ba..79bc35f8cb 100644 --- a/test/drb/test_drbssl.rb +++ b/test/drb/test_drbssl.rb @@ -5,6 +5,8 @@ begin rescue LoadError end +module DRbTests + if Object.const_defined?("OpenSSL") @@ -59,4 +61,6 @@ class TestDRbSSLAry < Test::Unit::TestCase end +end + end diff --git a/test/drb/test_drbunix.rb b/test/drb/test_drbunix.rb index ffc09e25b3..e20625e70d 100644 --- a/test/drb/test_drbunix.rb +++ b/test/drb/test_drbunix.rb @@ -5,6 +5,8 @@ begin rescue LoadError end +module DRbTests + if Object.const_defined?("UNIXServer") @@ -43,4 +45,6 @@ class TestDRbUNIXAry < Test::Unit::TestCase end +end + end diff --git a/test/drb/ut_array_drbssl.rb b/test/drb/ut_array_drbssl.rb index a56695dcd1..fa9afa6abd 100644 --- a/test/drb/ut_array_drbssl.rb +++ b/test/drb/ut_array_drbssl.rb @@ -9,7 +9,9 @@ if __FILE__ == $0 it end - TEST_KEY_DH1024 = OpenSSL::PKey::DH.new <<-_end_of_pem_ + module DRbTests + + TEST_KEY_DH1024 = OpenSSL::PKey::DH.new <<-_end_of_pem_ -----BEGIN DH PARAMETERS----- MIGHAoGBAKnKQ8MNK6nYZzLrrcuTsLxuiJGXoOO5gT+tljOTbHBuiktdMTITzIY0 pFxIvjG05D7HoBZQfrR0c92NGWPkAiCkhQKB8JCbPVzwNLDy6DZ0pmofDKrEsYHG @@ -17,10 +19,12 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC -----END DH PARAMETERS----- _end_of_pem_ - TEST_KEY_DH1024.priv_key = OpenSSL::BN.new("48561834C67E65FFD2A9B47F41E5E78FDC95C387428FDB1E4B0188B64D1643C3A8D3455B945B7E8C4D166010C7C2CE23BFB9BEF43D0348FE7FA5284B0225E7FE1537546D114E3D8A4411B9B9351AB451E1A358F50ED61B1F00DA29336EEBBD649980AC86D76AF8BBB065298C2052672EEF3EF13AB47A15275FC2836F3AC74CEA", 16) + TEST_KEY_DH1024.priv_key = OpenSSL::BN.new("48561834C67E65FFD2A9B47F41E5E78FDC95C387428FDB1E4B0188B64D1643C3A8D3455B945B7E8C4D166010C7C2CE23BFB9BEF43D0348FE7FA5284B0225E7FE1537546D114E3D8A4411B9B9351AB451E1A358F50ED61B1F00DA29336EEBBD649980AC86D76AF8BBB065298C2052672EEF3EF13AB47A15275FC2836F3AC74CEA", 16) + + end config = Hash.new - config[:SSLTmpDhCallback] = proc { TEST_KEY_DH1024 } + config[:SSLTmpDhCallback] = proc { DRbTests::TEST_KEY_DH1024 } config[:SSLVerifyMode] = OpenSSL::SSL::VERIFY_PEER config[:SSLVerifyCallback] = lambda{|ok,x509_store| true diff --git a/test/drb/ut_drb.rb b/test/drb/ut_drb.rb index c6cc0590f1..c2a5f62331 100644 --- a/test/drb/ut_drb.rb +++ b/test/drb/ut_drb.rb @@ -2,6 +2,8 @@ require 'drb/drb' require 'drb/extserv' require 'timeout' +module DRbTests + class XArray < Array def initialize(ary) ary.each do |x| @@ -147,6 +149,8 @@ class DRbEx end end +end + if __FILE__ == $0 def ARGV.shift it = super() @@ -156,7 +160,7 @@ if __FILE__ == $0 DRb::DRbServer.default_argc_limit(8) DRb::DRbServer.default_load_limit(4096) - DRb.start_service('druby://localhost:0', DRbEx.new) + DRb.start_service('druby://localhost:0', DRbTests::DRbEx.new) es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) DRb.thread.join es.stop_service if es.alive? diff --git a/test/drb/ut_drb_drbssl.rb b/test/drb/ut_drb_drbssl.rb index 1e270371d5..b6d1c12262 100644 --- a/test/drb/ut_drb_drbssl.rb +++ b/test/drb/ut_drb_drbssl.rb @@ -8,7 +8,9 @@ if __FILE__ == $0 it end - TEST_KEY_DH1024 = OpenSSL::PKey::DH.new <<-_end_of_pem_ + module DRbTests + + TEST_KEY_DH1024 = OpenSSL::PKey::DH.new <<-_end_of_pem_ -----BEGIN DH PARAMETERS----- MIGHAoGBAKnKQ8MNK6nYZzLrrcuTsLxuiJGXoOO5gT+tljOTbHBuiktdMTITzIY0 pFxIvjG05D7HoBZQfrR0c92NGWPkAiCkhQKB8JCbPVzwNLDy6DZ0pmofDKrEsYHG @@ -16,10 +18,12 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC -----END DH PARAMETERS----- _end_of_pem_ - TEST_KEY_DH1024.priv_key = OpenSSL::BN.new("48561834C67E65FFD2A9B47F41E5E78FDC95C387428FDB1E4B0188B64D1643C3A8D3455B945B7E8C4D166010C7C2CE23BFB9BEF43D0348FE7FA5284B0225E7FE1537546D114E3D8A4411B9B9351AB451E1A358F50ED61B1F00DA29336EEBBD649980AC86D76AF8BBB065298C2052672EEF3EF13AB47A15275FC2836F3AC74CEA", 16) + TEST_KEY_DH1024.priv_key = OpenSSL::BN.new("48561834C67E65FFD2A9B47F41E5E78FDC95C387428FDB1E4B0188B64D1643C3A8D3455B945B7E8C4D166010C7C2CE23BFB9BEF43D0348FE7FA5284B0225E7FE1537546D114E3D8A4411B9B9351AB451E1A358F50ED61B1F00DA29336EEBBD649980AC86D76AF8BBB065298C2052672EEF3EF13AB47A15275FC2836F3AC74CEA", 16) + + end config = Hash.new - config[:SSLTmpDhCallback] = proc { TEST_KEY_DH1024 } + config[:SSLTmpDhCallback] = proc { DRbTests::TEST_KEY_DH1024 } config[:SSLVerifyMode] = OpenSSL::SSL::VERIFY_PEER config[:SSLVerifyCallback] = lambda{|ok,x509_store| true @@ -29,7 +33,7 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC DRb::DRbServer.default_argc_limit(8) DRb::DRbServer.default_load_limit(4096) - DRb.start_service('drbssl://localhost:0', DRbEx.new, config) + DRb.start_service('drbssl://localhost:0', DRbTests::DRbEx.new, config) es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) DRb.thread.join es.stop_service if es.alive? diff --git a/test/drb/ut_drb_drbunix.rb b/test/drb/ut_drb_drbunix.rb index 83ae31e903..c997d2469d 100644 --- a/test/drb/ut_drb_drbunix.rb +++ b/test/drb/ut_drb_drbunix.rb @@ -9,7 +9,7 @@ if __FILE__ == $0 DRb::DRbServer.default_argc_limit(8) DRb::DRbServer.default_load_limit(4096) - DRb.start_service('drbunix:', DRbEx.new) + DRb.start_service('drbunix:', DRbTests::DRbEx.new) es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) DRb.thread.join es.stop_service if es.alive? diff --git a/test/drb/ut_eq.rb b/test/drb/ut_eq.rb index 7a0e04126c..cc86158363 100644 --- a/test/drb/ut_eq.rb +++ b/test/drb/ut_eq.rb @@ -1,6 +1,8 @@ require 'drb/drb' require 'drb/extserv' +module DRbTests + class Foo include DRbUndumped end @@ -17,6 +19,8 @@ class Bar end end +end + if __FILE__ == $0 def ARGV.shift it = super() @@ -24,8 +28,9 @@ if __FILE__ == $0 it end - DRb.start_service('druby://localhost:0', Bar.new) + DRb.start_service('druby://localhost:0', DRbTests::Bar.new) es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) DRb.thread.join es.stop_service if es.alive? end + diff --git a/test/drb/ut_eval.rb b/test/drb/ut_eval.rb index 1dbf8a5c50..c456790fd9 100644 --- a/test/drb/ut_eval.rb +++ b/test/drb/ut_eval.rb @@ -1,6 +1,8 @@ require 'drb/drb' require 'drb/extserv' +module DRbTests + class EvalAttack def initialize @four = DRb::DRbServer.new('druby://localhost:0', self, {:safe_level => 4}) @@ -15,6 +17,8 @@ class EvalAttack end end +end + if __FILE__ == $0 def ARGV.shift @@ -25,7 +29,7 @@ if __FILE__ == $0 $SAFE = 1 - DRb.start_service('druby://localhost:0', EvalAttack.new, {:safe_level => 2}) + DRb.start_service('druby://localhost:0', DRbTests::EvalAttack.new, {:safe_level => 2}) es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) DRb.thread.join es.stop_service if es.alive? diff --git a/test/drb/ut_large.rb b/test/drb/ut_large.rb index ab36c1b4a8..c2fbd3e184 100644 --- a/test/drb/ut_large.rb +++ b/test/drb/ut_large.rb @@ -2,6 +2,8 @@ require 'drb/drb' require 'drb/extserv' require 'timeout' +module DRbTests + class DRbLarge include DRbUndumped @@ -22,6 +24,8 @@ class DRbLarge end end +end + if __FILE__ == $0 def ARGV.shift it = super() @@ -31,7 +35,7 @@ if __FILE__ == $0 DRb::DRbServer.default_argc_limit(3) DRb::DRbServer.default_load_limit(100000) - DRb.start_service('druby://localhost:0', DRbLarge.new) + DRb.start_service('druby://localhost:0', DRbTests::DRbLarge.new) es = DRb::ExtServ.new(ARGV.shift, ARGV.shift) DRb.thread.join es.stop_service if es.alive? diff --git a/test/drb/ut_timerholder.rb b/test/drb/ut_timerholder.rb index 6f66dd3393..6c62ea7726 100644 --- a/test/drb/ut_timerholder.rb +++ b/test/drb/ut_timerholder.rb @@ -2,6 +2,8 @@ require 'runit/testcase' require 'runit/cui/testrunner' require 'timerholder' +module DRbTests + class TimerHolderTest < RUNIT::TestCase def do_test(timeout, keeper_sleep = nil) holder = TimerHolder.new(timeout) @@ -44,6 +46,8 @@ class TimerHolderTest < RUNIT::TestCase end end -if __FILE__ == $0 - RUNIT::CUI::TestRunner.run(TimerHolderTest.suite) +end + +if __FILE__ == $0 + RUNIT::CUI::TestRunner.run(DRbTests::TimerHolderTest.suite) end