зеркало из https://github.com/github/ruby.git
* test/test_syslog.rb (TestSyslog#test_log): Do not be too
specific about the log line format. Fixes #5081. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
700aeee754
Коммит
39eea54cfe
|
@ -1,3 +1,8 @@
|
|||
Fri Aug 5 17:14:11 2011 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* test/test_syslog.rb (TestSyslog#test_log): Do not be too
|
||||
specific about the log line format. Fixes #5081.
|
||||
|
||||
Fri Aug 5 15:57:10 2011 Naohisa Goto <ngotogenome@gmail.com>
|
||||
|
||||
* complex.c (f_signbit): fix compile error in gcc4 on Solaris with
|
||||
|
|
|
@ -115,6 +115,10 @@ class TestSyslog < Test::Unit::TestCase
|
|||
Syslog.close if Syslog.opened?
|
||||
end
|
||||
|
||||
def syslog_line_regex(ident, message)
|
||||
/(?:^| )#{Regexp.quote(ident)}(?:\[([1-9][0-9]*)\])?(?: |[: ].* )#{Regexp.quote(message)}$/
|
||||
end
|
||||
|
||||
def test_log
|
||||
stderr = IO::pipe
|
||||
|
||||
|
@ -145,11 +149,23 @@ class TestSyslog < Test::Unit::TestCase
|
|||
return unless Syslog.const_defined?(:LOG_PERROR)
|
||||
|
||||
2.times {
|
||||
assert_equal("syslog_test: test1 - hello, world!\n", stderr[0].gets)
|
||||
re = syslog_line_regex("syslog_test", "test1 - hello, world!")
|
||||
line = stderr[0].gets
|
||||
m = re.match(line)
|
||||
assert_not_nil(m)
|
||||
if m[1]
|
||||
# pid is written regardless of LOG_PID on OS X 10.7+
|
||||
assert_equal(pid, m[1].to_i)
|
||||
end
|
||||
}
|
||||
|
||||
2.times {
|
||||
assert_equal(format("syslog_test[%d]: test2 - pid\n", pid), stderr[0].gets)
|
||||
re = syslog_line_regex("syslog_test", "test2 - pid")
|
||||
line = stderr[0].gets
|
||||
m = re.match(line)
|
||||
assert_not_nil(m)
|
||||
assert_not_nil(m[1])
|
||||
assert_equal(pid, m[1].to_i)
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче