summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/drb/drbtest.rb2
-rw-r--r--test/drb/ut_drb.rb2
-rw-r--r--test/io/nonblock/test_flush.rb2
-rw-r--r--test/lib/test/unit.rb4
-rw-r--r--test/openssl/test_ssl_session.rb4
-rw-r--r--test/resolv/test_dns.rb4
-rw-r--r--test/ruby/test_io_m17n.rb2
-rw-r--r--test/ruby/test_process.rb2
-rw-r--r--test/ruby/test_readpartial.rb4
-rw-r--r--test/rubygems/test_gem_request_connection_pools.rb2
-rw-r--r--test/rubygems/test_gem_stream_ui.rb12
-rw-r--r--test/socket/test_nonblock.rb4
-rw-r--r--test/test_timeout.rb10
-rw-r--r--test/testunit/test_parallel.rb28
-rw-r--r--test/thread/test_queue.rb2
-rw-r--r--test/webrick/test_httpserver.rb2
16 files changed, 43 insertions, 43 deletions
diff --git a/test/drb/drbtest.rb b/test/drb/drbtest.rb
index b2576d8e13..11b542a4ee 100644
--- a/test/drb/drbtest.rb
+++ b/test/drb/drbtest.rb
@@ -27,7 +27,7 @@ class DRbService
@server || @@server
end
def self.ext_service(name)
- timeout(100, RuntimeError) do
+ Timeout.timeout(100, RuntimeError) do
manager.service(name)
end
end
diff --git a/test/drb/ut_drb.rb b/test/drb/ut_drb.rb
index c2a5f62331..0dd0988a7d 100644
--- a/test/drb/ut_drb.rb
+++ b/test/drb/ut_drb.rb
@@ -53,7 +53,7 @@ class DRbEx
end
def do_timeout(n)
- timeout(0.1) do
+ Timeout.timeout(0.1) do
n.sleep(2)
end
end
diff --git a/test/io/nonblock/test_flush.rb b/test/io/nonblock/test_flush.rb
index ab54205174..70e65cceed 100644
--- a/test/io/nonblock/test_flush.rb
+++ b/test/io/nonblock/test_flush.rb
@@ -28,7 +28,7 @@ class TestIONonblock < Test::Unit::TestCase
w.flush
w << "a" * 4096
result = ""
- timeout(10) {
+ Timeout.timeout(10) {
t0 = Thread.new {
Thread.pass
w.close
diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb
index 3c022b71a5..0473ddb524 100644
--- a/test/lib/test/unit.rb
+++ b/test/lib/test/unit.rb
@@ -292,7 +292,7 @@ module Test
return if @workers.empty?
@workers.reject! do |worker|
begin
- timeout(1) do
+ Timeout.timeout(1) do
worker.quit
end
rescue Errno::EPIPE
@@ -303,7 +303,7 @@ module Test
return if @workers.empty?
begin
- timeout(0.2 * @workers.size) do
+ Timeout.timeout(0.2 * @workers.size) do
Process.waitall
end
rescue Timeout::Error
diff --git a/test/openssl/test_ssl_session.rb b/test/openssl/test_ssl_session.rb
index 16432bcbb0..0c384c731a 100644
--- a/test/openssl/test_ssl_session.rb
+++ b/test/openssl/test_ssl_session.rb
@@ -44,7 +44,7 @@ tddwpBAEDjcwMzA5NTYzMTU1MzAwpQMCARM=
end
def test_session
- timeout(5) do
+ Timeout.timeout(5) do
start_server(OpenSSL::SSL::VERIFY_NONE, true) do |server, port|
sock = TCPSocket.new("127.0.0.1", port)
ctx = OpenSSL::SSL::SSLContext.new("TLSv1")
@@ -361,7 +361,7 @@ __EOS__
ssl.connect
last_client_session = ssl.session
ssl.close
- timeout(5) do
+ Timeout.timeout(5) do
Thread.pass until called.key?(:new)
assert(called.delete(:new))
Thread.pass until called.key?(:remove)
diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb
index d7e5c3683a..e7857248ce 100644
--- a/test/resolv/test_dns.rb
+++ b/test/resolv/test_dns.rb
@@ -53,7 +53,7 @@ class TestResolvDNS < Test::Unit::TestCase
}
}
server_thread = Thread.new {
- msg, (_, client_port, _, client_address) = timeout(5) {u.recvfrom(4096)}
+ msg, (_, client_port, _, client_address) = Timeout.timeout(5) {u.recvfrom(4096)}
id, word2, qdcount, ancount, nscount, arcount = msg.unpack("nnnnnn")
qr = (word2 & 0x8000) >> 15
opcode = (word2 & 0x7800) >> 11
@@ -160,7 +160,7 @@ class TestResolvDNS < Test::Unit::TestCase
# A rase condition here.
# Another program may use the port.
# But no way to prevent it.
- timeout(5) do
+ Timeout.timeout(5) do
Resolv::DNS.open(:nameserver_port => [[host, port]]) {|dns|
assert_equal([], dns.getresources("test-no-server.example.org", Resolv::DNS::Resource::IN::A))
}
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index c464bceae0..4382824844 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -468,7 +468,7 @@ EOT
w.close
end,
proc do |r|
- timeout(1) {
+ Timeout.timeout(1) {
assert_equal("before \xa2\xa2".encode("utf-8", "euc-jp"),
r.gets(rs))
}
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 02ba47fb35..e4d36f075b 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -1591,7 +1591,7 @@ class TestProcess < Test::Unit::TestCase
with_tmpchdir do
assert_nothing_raised('[ruby-dev:12261]') do
- timeout(3) do
+ Timeout.timeout(3) do
pid = spawn('yes | ls')
Process.waitpid pid
end
diff --git a/test/ruby/test_readpartial.rb b/test/ruby/test_readpartial.rb
index 7f2ec65ac7..bc84da7d12 100644
--- a/test/ruby/test_readpartial.rb
+++ b/test/ruby/test_readpartial.rb
@@ -51,7 +51,7 @@ class TestReadPartial < Test::Unit::TestCase
assert_equal('ab', r.readpartial(2))
assert_equal('c', r.readpartial(2))
assert_raise(Timeout::Error) {
- timeout(0.1) { r.readpartial(2) }
+ Timeout.timeout(0.1) { r.readpartial(2) }
}
}
end
@@ -65,7 +65,7 @@ class TestReadPartial < Test::Unit::TestCase
assert_equal("f\n", r.readpartial(4096))
assert_equal("ghi\n", r.readpartial(4096))
assert_raise(Timeout::Error) {
- timeout(0.1) { r.readpartial(2) }
+ Timeout.timeout(0.1) { r.readpartial(2) }
}
}
end
diff --git a/test/rubygems/test_gem_request_connection_pools.rb b/test/rubygems/test_gem_request_connection_pools.rb
index 403f7679f8..1944a4f351 100644
--- a/test/rubygems/test_gem_request_connection_pools.rb
+++ b/test/rubygems/test_gem_request_connection_pools.rb
@@ -118,7 +118,7 @@ class TestGemRequestConnectionPool < Gem::TestCase
pool.checkout
t1 = Thread.new {
- timeout(1) do
+ Timeout.timeout(1) do
pool.checkout
end
}
diff --git a/test/rubygems/test_gem_stream_ui.rb b/test/rubygems/test_gem_stream_ui.rb
index f4835685a1..bea187e8f3 100644
--- a/test/rubygems/test_gem_stream_ui.rb
+++ b/test/rubygems/test_gem_stream_ui.rb
@@ -38,7 +38,7 @@ class TestGemStreamUI < Gem::TestCase
skip 'TTY detection broken on windows' if
Gem.win_platform? unless RUBY_VERSION > '1.9.2'
- timeout(1) do
+ Timeout.timeout(1) do
expected_answer = "Arthur, King of the Britons"
@in.string = "#{expected_answer}\n"
actual_answer = @sui.ask("What is your name?")
@@ -52,7 +52,7 @@ class TestGemStreamUI < Gem::TestCase
@in.tty = false
- timeout(0.1) do
+ Timeout.timeout(0.1) do
answer = @sui.ask("what is your favorite color?")
assert_equal nil, answer
end
@@ -62,7 +62,7 @@ class TestGemStreamUI < Gem::TestCase
skip 'Always uses $stdin on windows' if
Gem.win_platform? unless RUBY_VERSION > '1.9.2'
- timeout(1) do
+ Timeout.timeout(1) do
expected_answer = "Arthur, King of the Britons"
@in.string = "#{expected_answer}\n"
actual_answer = @sui.ask_for_password("What is your name?")
@@ -76,7 +76,7 @@ class TestGemStreamUI < Gem::TestCase
@in.tty = false
- timeout(0.1) do
+ Timeout.timeout(0.1) do
answer = @sui.ask_for_password("what is the airspeed velocity of an unladen swallow?")
assert_equal nil, answer
end
@@ -88,7 +88,7 @@ class TestGemStreamUI < Gem::TestCase
@in.tty = false
- timeout(0.1) do
+ Timeout.timeout(0.1) do
answer = @sui.ask_yes_no("do coconuts migrate?", false)
assert_equal false, answer
@@ -103,7 +103,7 @@ class TestGemStreamUI < Gem::TestCase
@in.tty = false
- timeout(0.1) do
+ Timeout.timeout(0.1) do
assert_raises(Gem::OperationNotSupportedError) do
@sui.ask_yes_no("do coconuts migrate?")
end
diff --git a/test/socket/test_nonblock.rb b/test/socket/test_nonblock.rb
index 0853a15d00..fc2cdbf6ab 100644
--- a/test/socket/test_nonblock.rb
+++ b/test/socket/test_nonblock.rb
@@ -102,7 +102,7 @@ class TestSocketNonblock < Test::Unit::TestCase
assert_raise(IO::WaitReadable) { u1.recvfrom_nonblock(100) }
u2.send("", 0, u1.getsockname)
assert_nothing_raised("cygwin 1.5.19 has a problem to send an empty UDP packet. [ruby-dev:28915]") {
- timeout(1) { IO.select [u1] }
+ Timeout.timeout(1) { IO.select [u1] }
}
mesg, inet_addr = u1.recvfrom_nonblock(100)
assert_equal("", mesg)
@@ -124,7 +124,7 @@ class TestSocketNonblock < Test::Unit::TestCase
assert_raise(IO::WaitReadable) { u1.recv_nonblock(100) }
u2.send("", 0, u1.getsockname)
assert_nothing_raised("cygwin 1.5.19 has a problem to send an empty UDP packet. [ruby-dev:28915]") {
- timeout(1) { IO.select [u1] }
+ Timeout.timeout(1) { IO.select [u1] }
}
mesg = u1.recv_nonblock(100)
assert_equal("", mesg)
diff --git a/test/test_timeout.rb b/test/test_timeout.rb
index fcaf7154d7..88a9b82099 100644
--- a/test/test_timeout.rb
+++ b/test/test_timeout.rb
@@ -6,7 +6,7 @@ class TestTimeout < Test::Unit::TestCase
def test_queue
q = Queue.new
assert_raise(Timeout::Error, "[ruby-dev:32935]") {
- timeout(0.01) { q.pop }
+ Timeout.timeout(0.01) { q.pop }
}
end
@@ -28,7 +28,7 @@ class TestTimeout < Test::Unit::TestCase
bug8730 = '[Bug #8730]'
e = nil
assert_raise_with_message(Timeout::Error, /execution expired/, bug8730) do
- timeout 0.01 do
+ Timeout.timeout 0.01 do
begin
sleep 3
rescue Exception => e
@@ -42,7 +42,7 @@ class TestTimeout < Test::Unit::TestCase
exc = Class.new(RuntimeError)
e = nil
assert_nothing_raised(exc) do
- timeout 0.01, exc do
+ Timeout.timeout 0.01, exc do
begin
sleep 3
rescue exc => e
@@ -58,10 +58,10 @@ class TestTimeout < Test::Unit::TestCase
def initialize(msg) super end
end
assert_nothing_raised(ArgumentError, bug9354) do
- assert_equal(:ok, timeout(100, err) {:ok})
+ assert_equal(:ok, Timeout.timeout(100, err) {:ok})
end
assert_raise_with_message(err, /execution expired/) do
- timeout 0.01, err do
+ Timeout.timeout 0.01, err do
sleep 3
end
end
diff --git a/test/testunit/test_parallel.rb b/test/testunit/test_parallel.rb
index db3f47e2a5..f068b344df 100644
--- a/test/testunit/test_parallel.rb
+++ b/test/testunit/test_parallel.rb
@@ -22,7 +22,7 @@ module TestParallel
@worker_in.puts "quit"
rescue IOError, Errno::EPIPE
end
- timeout(2) do
+ Timeout.timeout(2) do
Process.waitpid(@worker_pid)
end
rescue Timeout::Error
@@ -38,7 +38,7 @@ module TestParallel
end
def test_run
- timeout(10) do
+ Timeout.timeout(10) do
assert_match(/^ready/,@worker_out.gets)
@worker_in.puts "run #{TESTS}/ptest_first.rb test"
assert_match(/^okay/,@worker_out.gets)
@@ -49,7 +49,7 @@ module TestParallel
end
def test_run_multiple_testcase_in_one_file
- timeout(10) do
+ Timeout.timeout(10) do
assert_match(/^ready/,@worker_out.gets)
@worker_in.puts "run #{TESTS}/ptest_second.rb test"
assert_match(/^okay/,@worker_out.gets)
@@ -62,7 +62,7 @@ module TestParallel
end
def test_accept_run_command_multiple_times
- timeout(10) do
+ Timeout.timeout(10) do
assert_match(/^ready/,@worker_out.gets)
@worker_in.puts "run #{TESTS}/ptest_first.rb test"
assert_match(/^okay/,@worker_out.gets)
@@ -80,7 +80,7 @@ module TestParallel
end
def test_p
- timeout(10) do
+ Timeout.timeout(10) do
@worker_in.puts "run #{TESTS}/ptest_first.rb test"
while buf = @worker_out.gets
break if /^p (.+?)$/ =~ buf
@@ -90,7 +90,7 @@ module TestParallel
end
def test_done
- timeout(10) do
+ Timeout.timeout(10) do
@worker_in.puts "run #{TESTS}/ptest_forth.rb test"
7.times { @worker_out.gets }
buf = @worker_out.gets
@@ -115,7 +115,7 @@ module TestParallel
end
def test_quit
- timeout(10) do
+ Timeout.timeout(10) do
@worker_in.puts "quit"
assert_match(/^bye$/m,@worker_out.read)
end
@@ -134,7 +134,7 @@ module TestParallel
def teardown
begin
if @test_pid
- timeout(2) do
+ Timeout.timeout(2) do
Process.waitpid(@test_pid)
end
end
@@ -151,40 +151,40 @@ module TestParallel
"--ruby", @options[:ruby].join(" "),
"-j","0", out: File::NULL, err: o)
o.close
- timeout(10) {
+ Timeout.timeout(10) {
assert_match(/Error: parameter of -j option should be greater than 0/,@test_out.read)
}
end
def test_should_run_all_without_any_leaks
spawn_runner
- buf = timeout(10){@test_out.read}
+ buf = Timeout.timeout(10) {@test_out.read}
assert_match(/^[SFE\.]{9}$/,buf)
end
def test_should_retry_failed_on_workers
spawn_runner
- buf = timeout(10){@test_out.read}
+ buf = Timeout.timeout(10) {@test_out.read}
assert_match(/^Retrying\.+$/,buf)
end
def test_no_retry_option
spawn_runner "--no-retry"
- buf = timeout(10){@test_out.read}
+ buf = Timeout.timeout(10) {@test_out.read}
refute_match(/^Retrying\.+$/,buf)
assert_match(/^ +\d+\) Failure:\nTestD#test_fail_at_worker/,buf)
end
def test_jobs_status
spawn_runner "--jobs-status"
- buf = timeout(10){@test_out.read}
+ buf = Timeout.timeout(10) {@test_out.read}
assert_match(/\d+=ptest_(first|second|third|forth) */,buf)
end
def test_separate
# this test depends to --jobs-status
spawn_runner "--jobs-status", "--separate"
- buf = timeout(10){@test_out.read}
+ buf = Timeout.timeout(10) {@test_out.read}
assert(buf.scan(/(\d+?)[:=]/).flatten.uniq.size > 1)
end
end
diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb
index 2bd71dbfc9..8fb0adca3f 100644
--- a/test/thread/test_queue.rb
+++ b/test/thread/test_queue.rb
@@ -239,7 +239,7 @@ class TestQueue < Test::Unit::TestCase
sleep 0.1
q << :s
assert_nothing_raised(Timeout::Error) do
- timeout(1) { th2.join }
+ Timeout.timeout(1) { th2.join }
end
ensure
[th1, th2].each do |th|
diff --git a/test/webrick/test_httpserver.rb b/test/webrick/test_httpserver.rb
index 5cd4ba5866..933aa0e02e 100644
--- a/test/webrick/test_httpserver.rb
+++ b/test/webrick/test_httpserver.rb
@@ -355,7 +355,7 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase
req = Net::HTTP::Get.new("/")
req['Connection'] = 'Keep-Alive'
begin
- timeout(2) do
+ Timeout.timeout(2) do
http.request(req){|res| assert_equal("foo", res.body) }
end
rescue Timeout::Error