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

ruby-changes:36219

From: akr <ko1@a...>
Date: Thu, 6 Nov 2014 21:23:32 +0900 (JST)
Subject: [ruby-changes:36219] akr:r48300 (trunk): * test/open-uri/test_open-uri.rb: Check empty webrick log.

akr	2014-11-06 21:23:22 +0900 (Thu, 06 Nov 2014)

  New Revision: 48300

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

  Log:
    * test/open-uri/test_open-uri.rb: Check empty webrick log.

  Modified files:
    trunk/ChangeLog
    trunk/test/open-uri/test_open-uri.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48299)
+++ ChangeLog	(revision 48300)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Nov  6 21:22:59 2014  Tanaka Akira  <akr@f...>
+
+	* test/open-uri/test_open-uri.rb: Check empty webrick log.
+
 Thu Nov  6 19:27:34 2014  NARUSE, Yui  <naruse@r...>
 
 	* re.c (unescape_nonascii): cast -1 for the case char is unsigned char.
Index: test/open-uri/test_open-uri.rb
===================================================================
--- test/open-uri/test_open-uri.rb	(revision 48299)
+++ test/open-uri/test_open-uri.rb	(revision 48300)
@@ -13,14 +13,9 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L13
   def NullLog.<<(arg)
   end
 
-  def with_http(capture_log=false)
-    if capture_log
-      log = StringIO.new('')
-      logger = WEBrick::Log.new(log, WEBrick::BasicLog::WARN)
-    else
-      log = nil
-      logger = WEBrick::Log.new($stdout, WEBrick::BasicLog::WARN)
-    end
+  def with_http(log_is_empty=true)
+    log = StringIO.new('')
+    logger = WEBrick::Log.new(log, WEBrick::BasicLog::WARN)
     Dir.mktmpdir {|dr|
       srv = WEBrick::HTTPServer.new({
         :DocumentRoot => dr,
@@ -38,6 +33,9 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L33
         th.join
       end
     }
+    if log_is_empty
+      assert_equal("", log.string)
+    end
   end
 
   def with_env(h)
@@ -83,7 +81,7 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L81
   end
 
   def test_404
-    with_http(true) {|srv, dr, url, log|
+    with_http(false) {|srv, dr, url, log|
       exc = assert_raise(OpenURI::HTTPError) { open("#{url}/not-exist") {} }
       assert_equal("404", exc.io.status[0])
       assert_match(%r{ERROR `/not-exist' not found}, log.string)
@@ -408,7 +406,7 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L406
   end
 
   def test_redirect_auth
-    with_http(true) {|srv, dr, url, log|
+    with_http(false) {|srv, dr, url, log|
       srv.mount_proc("/r1/") {|req, res| res.status = 301; res["location"] = "#{url}/r2" }
       srv.mount_proc("/r2/") {|req, res|
         if req["Authorization"] != "Basic #{['user:pass'].pack('m').chomp}"

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

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