From: Eric Wong <e@80x24.org>
To: kgio-public@bogomips.org
Subject: [PATCH 2/2] tests: fix unused variable warnings from newer Rubies
Date: Wed, 30 Oct 2019 09:26:28 +0000 [thread overview]
Message-ID: <20191030092628.31661-3-e@80x24.org> (raw)
In-Reply-To: <20191030092628.31661-1-e@80x24.org>
Newer Rubies warn about more things...
---
test/test_accept_class.rb | 18 ++++++++++--------
test/test_connect_fd_leak.rb | 1 +
test/test_kgio_addr.rb | 1 +
test/test_poll.rb | 10 ++++------
test/test_tcp6_client_read_server_write.rb | 1 +
5 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/test/test_accept_class.rb b/test/test_accept_class.rb
index 0e1d172..01dc263 100644
--- a/test/test_accept_class.rb
+++ b/test/test_accept_class.rb
@@ -30,33 +30,35 @@ class TestAcceptClass < Test::Unit::TestCase
@host = ENV["TEST_HOST"] || '127.0.0.1'
@srv = Kgio::TCPServer.new(@host, 0)
@port = @srv.addr[1]
+ socks = []
Kgio.accept_class = Kgio::TCPSocket
- client = TCPSocket.new(@host, @port)
+ socks << TCPSocket.new(@host, @port)
assert_instance_of Kgio::TCPSocket, @srv.kgio_accept
- client = TCPSocket.new(@host, @port)
+ socks << TCPSocket.new(@host, @port)
IO.select([@srv])
assert_instance_of Kgio::TCPSocket, @srv.kgio_tryaccept
Kgio.accept_class = nil
- client = TCPSocket.new(@host, @port)
+ socks << TCPSocket.new(@host, @port)
assert_instance_of Kgio::Socket, @srv.kgio_accept
- client = TCPSocket.new(@host, @port)
+ socks << TCPSocket.new(@host, @port)
IO.select([@srv])
assert_instance_of Kgio::Socket, @srv.kgio_tryaccept
Kgio.accept_class = Kgio::UNIXSocket
- client = TCPSocket.new(@host, @port)
+ socks << TCPSocket.new(@host, @port)
assert_instance_of Kgio::UNIXSocket, @srv.kgio_accept
- client = TCPSocket.new(@host, @port)
+ socks << TCPSocket.new(@host, @port)
IO.select([@srv])
assert_instance_of Kgio::UNIXSocket, @srv.kgio_tryaccept
- client = TCPSocket.new(@host, @port)
+ socks << TCPSocket.new(@host, @port)
assert_instance_of FooSocket, @srv.kgio_accept(FooSocket)
- client = TCPSocket.new(@host, @port)
+ socks << TCPSocket.new(@host, @port)
IO.select([@srv])
assert_instance_of FooSocket, @srv.kgio_tryaccept(FooSocket)
+ socks.each(&:close)
end
end
diff --git a/test/test_connect_fd_leak.rb b/test/test_connect_fd_leak.rb
index 1dfc4cd..034fe5b 100644
--- a/test/test_connect_fd_leak.rb
+++ b/test/test_connect_fd_leak.rb
@@ -13,5 +13,6 @@ class TestConnectFDLeak < Test::Unit::TestCase
sock = Kgio::UNIXSocket.new(path)
rescue Errno::ENOENT
end while (nr += 1) < 10000
+ sock.close
end
end
diff --git a/test/test_kgio_addr.rb b/test/test_kgio_addr.rb
index 8650f5e..fc1dec7 100644
--- a/test/test_kgio_addr.rb
+++ b/test/test_kgio_addr.rb
@@ -15,5 +15,6 @@ class TestKgioAddr < Test::Unit::TestCase
s = accepted.kgio_addr!
assert_equal addr, s
assert_equal addr, accepted.instance_variable_get(:@kgio_addr)
+ client.close
end
end
diff --git a/test/test_poll.rb b/test/test_poll.rb
index 6463ef9..ab77bc9 100644
--- a/test/test_poll.rb
+++ b/test/test_poll.rb
@@ -43,7 +43,6 @@ class TestPoll < Test::Unit::TestCase
end
def test_poll_close
- foo = nil
thr = Thread.new { sleep 0.100; @wr.close }
t0 = Time.now
res = Kgio.poll({@rd => Kgio::POLLIN})
@@ -55,7 +54,6 @@ class TestPoll < Test::Unit::TestCase
def test_signal_close
orig = trap(:USR1) { @rd.close }
- res = nil
thr = Thread.new { sleep 0.100; Process.kill(:USR1, $$) }
t0 = Time.now
assert_raises(IOError) do
@@ -65,8 +63,8 @@ class TestPoll < Test::Unit::TestCase
diff = Time.now - t0
thr.join
assert diff >= 0.010, "diff=#{diff}"
- ensure
- trap(:USR1, orig)
+ ensure
+ trap(:USR1, orig)
end
def test_poll_EINTR
@@ -83,8 +81,8 @@ class TestPoll < Test::Unit::TestCase
assert_nil res
assert diff >= 1.0, "diff=#{diff}"
assert ok
- ensure
- trap(:USR1, orig)
+ ensure
+ trap(:USR1, orig)
end
def test_poll_signal_torture
diff --git a/test/test_tcp6_client_read_server_write.rb b/test/test_tcp6_client_read_server_write.rb
index 4ad330f..35c6463 100644
--- a/test/test_tcp6_client_read_server_write.rb
+++ b/test/test_tcp6_client_read_server_write.rb
@@ -3,6 +3,7 @@ require './test/lib_read_write'
begin
tmp = TCPServer.new(ENV["TEST_HOST6"] || '::1', 0)
ipv6_enabled = true
+ tmp.close
rescue => e
warn "skipping IPv6 tests, host does not seem to be IPv6 enabled:"
warn " #{e.class}: #{e}"
prev parent reply other threads:[~2019-10-30 9:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-30 9:26 [PATCH 0/2] Ruby warning fixes Eric Wong
2019-10-30 9:26 ` [PATCH 1/2] test: fix warnings with RUBYOPT=-w Eric Wong
2019-10-30 9:26 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/kgio/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191030092628.31661-3-e@80x24.org \
--to=e@80x24.org \
--cc=kgio-public@bogomips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/kgio.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).