ruby-changes:20838
From: kosaki <ko1@a...>
Date: Mon, 8 Aug 2011 00:11:43 +0900 (JST)
Subject: [ruby-changes:20838] kosaki:r32887 (ruby_1_9_3): merge revision(s) 32859:
kosaki 2011-08-08 00:11:03 +0900 (Mon, 08 Aug 2011) New Revision: 32887 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32887 Log: merge revision(s) 32859: * test/test_syslog.rb (TestSyslog#test_log): Do not be too specific about the log line format. Fixes #5081. Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/test/test_syslog.rb branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 32886) +++ ruby_1_9_3/ChangeLog (revision 32887) @@ -1,3 +1,8 @@ +Mon Aug 8 00:10:45 2011 Akinori MUSHA <knu@i...> + + * test/test_syslog.rb (TestSyslog#test_log): Do not be too + specific about the log line format. Fixes #5081. + Sun Aug 7 23:39:44 2011 KOSAKI Motohiro <kosaki.motohiro@g...> * time.c (rb_strftime_alloc): raise ERANGE if width is too large. Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 32886) +++ ruby_1_9_3/version.h (revision 32887) @@ -1,10 +1,10 @@ #define RUBY_VERSION "1.9.3" #define RUBY_PATCHLEVEL -1 -#define RUBY_RELEASE_DATE "2011-08-07" +#define RUBY_RELEASE_DATE "2011-08-08" #define RUBY_RELEASE_YEAR 2011 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 7 +#define RUBY_RELEASE_DAY 8 #include "ruby/version.h" Index: ruby_1_9_3/test/test_syslog.rb =================================================================== --- ruby_1_9_3/test/test_syslog.rb (revision 32886) +++ ruby_1_9_3/test/test_syslog.rb (revision 32887) @@ -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/