* [PATCH 0/2] Ruby warning fixes
@ 2019-10-30 9:26 Eric Wong
2019-10-30 9:26 ` [PATCH 1/2] test: fix warnings with RUBYOPT=-w Eric Wong
2019-10-30 9:26 ` [PATCH 2/2] tests: fix unused variable warnings from newer Rubies Eric Wong
0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2019-10-30 9:26 UTC (permalink / raw)
To: kgio-public
Newer Rubies warn about more things
Eric Wong (2):
test: fix warnings with RUBYOPT=-w
tests: fix unused variable warnings from newer Rubies
test/lib_read_write.rb | 2 ++
test/lib_server_accept.rb | 11 +++++++----
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 +
test/test_tryopen.rb | 5 +++--
8 files changed, 29 insertions(+), 20 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] test: fix warnings with RUBYOPT=-w
2019-10-30 9:26 [PATCH 0/2] Ruby warning fixes Eric Wong
@ 2019-10-30 9:26 ` Eric Wong
2019-10-30 9:26 ` [PATCH 2/2] tests: fix unused variable warnings from newer Rubies Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2019-10-30 9:26 UTC (permalink / raw)
To: kgio-public
---
test/lib_read_write.rb | 2 ++
test/lib_server_accept.rb | 11 +++++++----
test/test_tryopen.rb | 5 +++--
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/test/lib_read_write.rb b/test/lib_read_write.rb
index 5f70964..a32919f 100644
--- a/test/lib_read_write.rb
+++ b/test/lib_read_write.rb
@@ -166,6 +166,7 @@ module LibReadWriteTest
rescue EOFError
break
rescue => e
+ warn "#{e.message} (#{e.class})"
end while true
dig.hexdigest
end
@@ -203,6 +204,7 @@ module LibReadWriteTest
rescue EOFError
break
rescue => e
+ warn "#{e.message} (#{e.class})"
end while true
dig.hexdigest
end
diff --git a/test/lib_server_accept.rb b/test/lib_server_accept.rb
index db0d120..fcf9c87 100644
--- a/test/lib_server_accept.rb
+++ b/test/lib_server_accept.rb
@@ -20,6 +20,7 @@ module LibServerAccept
b = @srv.kgio_tryaccept
assert_kind_of Kgio::Socket, b
assert_equal @host, b.kgio_addr
+ a.close
end
def test_tryaccept_flags
@@ -28,6 +29,7 @@ module LibServerAccept
b = @srv.kgio_tryaccept nil, 0
assert_kind_of Kgio::Socket, b
assert_equal 0, b.fcntl(Fcntl::F_GETFD)
+ a.close
end
def test_blocking_accept_flags
@@ -36,6 +38,7 @@ module LibServerAccept
b = @srv.kgio_accept nil, 0
assert_kind_of Kgio::Socket, b
assert_equal 0, b.fcntl(Fcntl::F_GETFD)
+ a.close
end
def test_tryaccept_fail
@@ -44,7 +47,7 @@ module LibServerAccept
def test_blocking_accept
t0 = Time.now
- pid = fork { sleep 1; a = client_connect; sleep }
+ pid = fork { sleep 1; a = client_connect; sleep; a.close }
b = @srv.kgio_accept
elapsed = Time.now - t0
assert_kind_of Kgio::Socket, b
@@ -57,7 +60,7 @@ module LibServerAccept
def test_blocking_accept_with_nonblock_socket
@srv.nonblock = true
t0 = Time.now
- pid = fork { sleep 1; a = client_connect; sleep }
+ pid = fork { sleep 1; a = client_connect; sleep; a.close }
b = @srv.kgio_accept
elapsed = Time.now - t0
assert_kind_of Kgio::Socket, b
@@ -67,7 +70,7 @@ module LibServerAccept
assert elapsed >= 1, "elapsed: #{elapsed}"
t0 = Time.now
- pid = fork { sleep 6; a = client_connect; sleep }
+ pid = fork { sleep 6; a = client_connect; sleep; a.close }
b = @srv.kgio_accept
elapsed = Time.now - t0
assert_kind_of Kgio::Socket, b
@@ -77,7 +80,7 @@ module LibServerAccept
assert elapsed >= 6, "elapsed: #{elapsed}"
t0 = Time.now
- pid = fork { sleep 1; a = client_connect; sleep }
+ pid = fork { sleep 1; a = client_connect; sleep; a.close }
b = @srv.kgio_accept
elapsed = Time.now - t0
assert_kind_of Kgio::Socket, b
diff --git a/test/test_tryopen.rb b/test/test_tryopen.rb
index abcbd37..2bbbc51 100644
--- a/test/test_tryopen.rb
+++ b/test/test_tryopen.rb
@@ -59,8 +59,9 @@ class TestTryopen < Test::Unit::TestCase
tmp.close!
file = Kgio::File.tryopen(path, IO::RDWR|IO::CREAT, 0000)
assert_equal 0100000, File.stat(path).mode
- ensure
- File.unlink path
+ file.close
+ ensure
+ File.unlink path
end
require "benchmark"
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] tests: fix unused variable warnings from newer Rubies
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
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2019-10-30 9:26 UTC (permalink / raw)
To: kgio-public
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}"
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-30 9:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/2] tests: fix unused variable warnings from newer Rubies Eric Wong
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).