ruby-changes:20811
From: knu <ko1@a...>
Date: Fri, 5 Aug 2011 17:26:53 +0900 (JST)
Subject: [ruby-changes:20811] knu:r32859 (trunk): * test/test_syslog.rb (TestSyslog#test_log): Do not be too
knu 2011-08-05 17:26:42 +0900 (Fri, 05 Aug 2011) New Revision: 32859 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32859 Log: * test/test_syslog.rb (TestSyslog#test_log): Do not be too specific about the log line format. Fixes #5081. Modified files: trunk/ChangeLog trunk/test/test_syslog.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 32858) +++ ChangeLog (revision 32859) @@ -1,3 +1,8 @@ +Fri Aug 5 17:14:11 2011 Akinori MUSHA <knu@i...> + + * 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@g...> * complex.c (f_signbit): fix compile error in gcc4 on Solaris with Index: test/test_syslog.rb =================================================================== --- test/test_syslog.rb (revision 32858) +++ test/test_syslog.rb (revision 32859) @@ -115,6 +115,10 @@ 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 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/