* 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:
knu 2011-08-05 08:26:42 +00:00
Родитель 700aeee754
Коммит 39eea54cfe
2 изменённых файлов: 23 добавлений и 2 удалений

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

@ -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