[前][次][番号順一覧][スレッド一覧]

ruby-changes:59812

From: Kazuhiro <ko1@a...>
Date: Sun, 26 Jan 2020 20:04:00 +0900 (JST)
Subject: [ruby-changes:59812] 838fa941f1 (master): Add more debug print

https://git.ruby-lang.org/ruby.git/commit/?id=838fa941f1

From 838fa941f157537ebaa98150fab7664bf602f356 Mon Sep 17 00:00:00 2001
From: Kazuhiro NISHIYAMA <zn@m...>
Date: Sun, 26 Jan 2020 19:52:16 +0900
Subject: Add more debug print

https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable11x/ruby-master/log/20200125T032406Z.fail.html.gz
```
IMAPTest#test_connection_closed_without_greeting [/export/home/rubyci/chkbuild-tmp/tmp/build/20200125T032406Z/ruby/test/net/imap/test_imap.rb:485]:
[Net::IMAP::Error] exception expected, not #<RuntimeError: {:"server before close"=>"#<TCPServer:fd 10, AF_INET6, ::1, 48515>", :sock_addr=>["AF_INET6", 48515, "::1", "::1"], :sock_peeraddr=>["AF_INET6", 35223, "::1", "::1"], :e=>#<Errno::EINVAL: Invalid argument - connect(2) for [::1]:48515>, :server=>#<TCPServer:(closed)>, :port=>48515, :server_addr=>"::1"}>.
```

diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb
index 33b305e..03692c2 100644
--- a/test/net/imap/test_imap.rb
+++ b/test/net/imap/test_imap.rb
@@ -472,25 +472,65 @@ class IMAPTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/net/imap/test_imap.rb#L472
   def test_connection_closed_without_greeting
     server = create_tcp_server
     port = server.addr[1]
-    h = {'server before close': server.inspect} # inspect info before close
+    h = {
+      server: server,
+      port: port,
+      server_created: {
+        server: server.inspect,
+        t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+      }
+    }
+    net_imap = Class.new(Net::IMAP) do
+      @@h = h
+      def tcp_socket(host, port)
+        @@h[:in_tcp_socket] = {
+          host: host,
+          port: port,
+          server: @@h[:server].inspect,
+          t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+        }
+        super
+      end
+    end
     start_server do
       begin
+        h[:in_start_server_before_accept] = {
+          t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+        }
         sock = server.accept
-        h[:sock_addr], h[:sock_peeraddr] = sock.addr, sock.peeraddr
+        h[:in_start_server] = {
+          sock_addr: sock.addr,
+          sock_peeraddr: sock.peeraddr,
+          t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+        }
         sock.close
+        h[:in_start_server_sock_closed] = {
+          t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+        }
       ensure
         server.close
       end
     end
     assert_raise(Net::IMAP::Error) do
-      #begin
-      Net::IMAP.new(server_addr, :port => port)
-      #rescue Net::IMAP::Error
-      #  raise Errno::EINVAL
-      #end
+      #Net::IMAP.new(server_addr, :port => port)
+      if true
+          net_imap.new(server_addr, :port => port)
+      else
+        # for testing debug print
+        begin
+          net_imap.new(server_addr, :port => port)
+        rescue Net::IMAP::Error
+          raise Errno::EINVAL
+        end
+      end
     rescue Errno::EINVAL => e # for debug on OpenCSW
-      h.merge!({e: e, server: server, port: port, server_addr: server_addr})
-      raise(h.inspect)
+      h[:in_rescue] = {
+        e: e,
+        server_addr: server_addr,
+        t: Process.clock_gettime(Process::CLOCK_MONOTONIC),
+      }
+      require 'pp'
+      raise(PP.pp(h, +''))
     end
   end
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]