ruby-changes:36245
From: akr <ko1@a...>
Date: Sun, 9 Nov 2014 09:51:19 +0900 (JST)
Subject: [ruby-changes:36245] akr:r48326 (trunk): * test/webrick: Refine log tests.
akr 2014-11-09 09:51:12 +0900 (Sun, 09 Nov 2014) New Revision: 48326 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48326 Log: * test/webrick: Refine log tests. Modified files: trunk/ChangeLog trunk/test/webrick/test_httpauth.rb trunk/test/webrick/utils.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 48325) +++ ChangeLog (revision 48326) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Nov 9 09:50:22 2014 Tanaka Akira <akr@f...> + + * test/webrick: Refine log tests. + Sun Nov 9 08:58:05 2014 Tanaka Akira <akr@f...> * defs/known_errors.def (EHWPOISON): New errno symbol. Index: test/webrick/test_httpauth.rb =================================================================== --- test/webrick/test_httpauth.rb (revision 48325) +++ test/webrick/test_httpauth.rb (revision 48326) @@ -61,11 +61,17 @@ class TestWEBrickHTTPAuth < Test::Unit:: https://github.com/ruby/ruby/blob/trunk/test/webrick/test_httpauth.rb#L61 http.request(g){|res| assert_not_equal("hoge", res.body, log.call)} } } - pat = /ERROR Basic WEBrick's realm: webrick: password unmatch\./ - assert_match(pat, log); log.sub!(pat, '') - pat = /ERROR WEBrick::HTTPStatus::Unauthorized/ - assert_match(pat, log); log.sub!(pat, '') - assert_not_match(/ERROR/, log) + log = log.lines.to_a + log.reject! {|line| /\A\s*\z/ =~ line } + pats = [ + /ERROR Basic WEBrick's realm: webrick: password unmatch\./, + /ERROR WEBrick::HTTPStatus::Unauthorized/ + ] + pats.each {|pat| + assert_operator(log, :grep, pat) + log.reject! {|line| pat =~ line } + } + assert_equal([], log) end def test_basic_auth3 @@ -148,15 +154,18 @@ class TestWEBrickHTTPAuth < Test::Unit:: https://github.com/ruby/ruby/blob/trunk/test/webrick/test_httpauth.rb#L154 end } } - pat = /ERROR Digest WEBrick's realm: no credentials in the request\./ - assert_match(pat, log); log.sub!(pat, '') - pat = /ERROR WEBrick::HTTPStatus::Unauthorized/ - assert_match(pat, log); log.sub!(pat, '') - pat = /ERROR Digest WEBrick's realm: webrick: digest unmatch\./ - assert_match(pat, log); log.sub!(pat, '') - pat = /ERROR WEBrick::HTTPStatus::Unauthorized/ - assert_match(pat, log); log.sub!(pat, '') - assert_not_match(/ERROR/, log) + log = log.lines.to_a + log.reject! {|line| /\A\s*\z/ =~ line } + pats = [ + /ERROR Digest WEBrick's realm: no credentials in the request\./, + /ERROR WEBrick::HTTPStatus::Unauthorized/, + /ERROR Digest WEBrick's realm: webrick: digest unmatch\./ + ] + pats.each {|pat| + assert_operator(log, :grep, pat) + log.reject! {|line| pat =~ line } + } + assert_equal([], log) end private Index: test/webrick/utils.rb =================================================================== --- test/webrick/utils.rb (revision 48325) +++ test/webrick/utils.rb (revision 48326) @@ -41,7 +41,7 @@ module TestWEBrick https://github.com/ruby/ruby/blob/trunk/test/webrick/utils.rb#L41 server = klass.new({ :BindAddress => "127.0.0.1", :Port => 0, :ServerType => Thread, - :Logger => WEBrick::Log.new(logger), + :Logger => WEBrick::Log.new(logger, WEBrick::BasicLog::WARN), :AccessLog => [[logger, ""]] }.update(config)) server_thread = server.start -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/