* test/webrick: Refine log tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2014-11-09 00:51:12 +00:00
Родитель f6695a95ea
Коммит 7044cea301
3 изменённых файлов: 28 добавлений и 15 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Sun Nov 9 09:50:22 2014 Tanaka Akira <akr@fsij.org>
* test/webrick: Refine log tests.
Sun Nov 9 08:58:05 2014 Tanaka Akira <akr@fsij.org> Sun Nov 9 08:58:05 2014 Tanaka Akira <akr@fsij.org>
* defs/known_errors.def (EHWPOISON): New errno symbol. * defs/known_errors.def (EHWPOISON): New errno symbol.

Просмотреть файл

@ -61,11 +61,17 @@ class TestWEBrickHTTPAuth < Test::Unit::TestCase
http.request(g){|res| assert_not_equal("hoge", res.body, log.call)} http.request(g){|res| assert_not_equal("hoge", res.body, log.call)}
} }
} }
pat = /ERROR Basic WEBrick's realm: webrick: password unmatch\./ log = log.lines.to_a
assert_match(pat, log); log.sub!(pat, '') log.reject! {|line| /\A\s*\z/ =~ line }
pat = /ERROR WEBrick::HTTPStatus::Unauthorized/ pats = [
assert_match(pat, log); log.sub!(pat, '') /ERROR Basic WEBrick's realm: webrick: password unmatch\./,
assert_not_match(/ERROR/, log) /ERROR WEBrick::HTTPStatus::Unauthorized/
]
pats.each {|pat|
assert_operator(log, :grep, pat)
log.reject! {|line| pat =~ line }
}
assert_equal([], log)
end end
def test_basic_auth3 def test_basic_auth3
@ -148,15 +154,18 @@ class TestWEBrickHTTPAuth < Test::Unit::TestCase
end end
} }
} }
pat = /ERROR Digest WEBrick's realm: no credentials in the request\./ log = log.lines.to_a
assert_match(pat, log); log.sub!(pat, '') log.reject! {|line| /\A\s*\z/ =~ line }
pat = /ERROR WEBrick::HTTPStatus::Unauthorized/ pats = [
assert_match(pat, log); log.sub!(pat, '') /ERROR Digest WEBrick's realm: no credentials in the request\./,
pat = /ERROR Digest WEBrick's realm: webrick: digest unmatch\./ /ERROR WEBrick::HTTPStatus::Unauthorized/,
assert_match(pat, log); log.sub!(pat, '') /ERROR Digest WEBrick's realm: webrick: digest unmatch\./
pat = /ERROR WEBrick::HTTPStatus::Unauthorized/ ]
assert_match(pat, log); log.sub!(pat, '') pats.each {|pat|
assert_not_match(/ERROR/, log) assert_operator(log, :grep, pat)
log.reject! {|line| pat =~ line }
}
assert_equal([], log)
end end
private private

Просмотреть файл

@ -41,7 +41,7 @@ module TestWEBrick
server = klass.new({ server = klass.new({
:BindAddress => "127.0.0.1", :Port => 0, :BindAddress => "127.0.0.1", :Port => 0,
:ServerType => Thread, :ServerType => Thread,
:Logger => WEBrick::Log.new(logger), :Logger => WEBrick::Log.new(logger, WEBrick::BasicLog::WARN),
:AccessLog => [[logger, ""]] :AccessLog => [[logger, ""]]
}.update(config)) }.update(config))
server_thread = server.start server_thread = server.start