diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-09-03 09:20:42 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-09-03 09:20:42 -0700 |
commit | b7c6846e317b0f2bfe4807aab34524c2a633947c (patch) | |
tree | 013a4590fada5dd821b5f85a376d54ffda7897b8 /test | |
parent | afaa8efb31094a831a68b383523f9bac46a244ac (diff) | |
download | clogger-b7c6846e317b0f2bfe4807aab34524c2a633947c.tar.gz |
Userspace buffering defaults are dangerous as the Ruby default IO objects do not do line-aware buffering. This makes the README examples with File.open much safer to use out-of-the-box for users of the pure-Ruby version. For users on the MRI C extension logging to regular files, this should not have any effect as we've optimized those to do unbuffered write(2) syscalls anyways.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_clogger.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_clogger.rb b/test/test_clogger.rb index 8e6604e..d3e315e 100644 --- a/test/test_clogger.rb +++ b/test/test_clogger.rb @@ -434,4 +434,23 @@ class TestClogger < Test::Unit::TestCase assert_equal "text/plain\n", str.string end + def test_clogger_synced + io = StringIO.new + logger = Struct.new(:sync, :io).new(false, io) + assert ! logger.sync + def logger.<<(str) + io << str + end + app = lambda { |env| [302, [ %w(a) ], []] } + cl = Clogger.new(app, :logger => logger) + assert logger.sync + end + + def test_clogger_unsyncable + logger = '' + assert ! logger.respond_to?('sync=') + app = lambda { |env| [302, [ %w(a) ], []] } + assert_nothing_raised { Clogger.new(app, :logger => logger) } + end + end |