aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_syslog.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-05 08:26:42 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-05 08:26:42 +0000
commit39eea54cfe59d69282271e75703fd053b377a2f0 (patch)
treef0e6b20fcd0d72d818e41c65d4ee9780222acd3f /test/test_syslog.rb
parent700aeee754648204314b644f24a75aaebe438ca7 (diff)
downloadruby-39eea54cfe59d69282271e75703fd053b377a2f0.tar.gz
* 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
Diffstat (limited to 'test/test_syslog.rb')
-rw-r--r--test/test_syslog.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/test_syslog.rb b/test/test_syslog.rb
index 063d3b1e11..4be12ff798 100644
--- a/test/test_syslog.rb
+++ b/test/test_syslog.rb
@@ -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