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

ruby-changes:36298

From: akr <ko1@a...>
Date: Tue, 11 Nov 2014 22:08:22 +0900 (JST)
Subject: [ruby-changes:36298] akr:r48379 (trunk): * test/net/http/test_https_proxy.rb: Use assert_join_threads.

akr	2014-11-11 22:08:01 +0900 (Tue, 11 Nov 2014)

  New Revision: 48379

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48379

  Log:
    * test/net/http/test_https_proxy.rb: Use assert_join_threads.

  Modified files:
    trunk/ChangeLog
    trunk/test/net/http/test_https_proxy.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48378)
+++ ChangeLog	(revision 48379)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Nov 11 22:07:20 2014  Tanaka Akira  <akr@f...>
+
+	* test/net/http/test_https_proxy.rb: Use assert_join_threads.
+
 Tue Nov 11 18:09:11 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* template/prelude.c.tmpl: move from tool/compile_prelude.rb and
Index: test/net/http/test_https_proxy.rb
===================================================================
--- test/net/http/test_https_proxy.rb	(revision 48378)
+++ test/net/http/test_https_proxy.rb	(revision 48379)
@@ -12,10 +12,9 @@ class HTTPSProxyTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/net/http/test_https_proxy.rb#L12
       skip 'autoload problem. see [ruby-dev:45021][Bug #5786]'
     end
 
-    t = nil
     TCPServer.open("127.0.0.1", 0) {|serv|
       _, port, _, _ = serv.addr
-      t = Thread.new {
+      client_thread = Thread.new {
         proxy = Net::HTTP.Proxy("127.0.0.1", port, 'user', 'password')
         http = proxy.new("foo.example.org", 8000)
         http.use_ssl = true
@@ -25,19 +24,23 @@ class HTTPSProxyTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/net/http/test_https_proxy.rb#L24
         rescue EOFError
         end
       }
-      sock = serv.accept
-      proxy_request = sock.gets("\r\n\r\n")
-      assert_equal(
-        "CONNECT foo.example.org:8000 HTTP/1.1\r\n" +
-        "Host: foo.example.org:8000\r\n" +
-        "Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==\r\n" +
-        "\r\n",
-        proxy_request,
-        "[ruby-dev:25673]")
-      sock.close
+      server_thread = Thread.new {
+        sock = serv.accept
+        begin
+          proxy_request = sock.gets("\r\n\r\n")
+          assert_equal(
+            "CONNECT foo.example.org:8000 HTTP/1.1\r\n" +
+            "Host: foo.example.org:8000\r\n" +
+            "Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==\r\n" +
+            "\r\n",
+            proxy_request,
+            "[ruby-dev:25673]")
+        ensure
+          sock.close
+        end
+      }
+      assert_join_threads([client_thread, server_thread])
     }
-  ensure
-    t.join if t
   end
 end if defined?(OpenSSL)
 

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

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