diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-06-08 03:26:43 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-06-08 03:26:43 +0000 |
commit | f09f5bc32b54e9d2e9f594fd2a2358af0a0f999a (patch) | |
tree | 90062f3dec7adfc3da17419a1ccf7566ace71793 /test | |
parent | 9a028876d23c7aab1420d81d3c001fbc91354538 (diff) | |
download | unicorn-f09f5bc32b54e9d2e9f594fd2a2358af0a0f999a.tar.gz |
IO#reopen in Rubinius seems to munge the O_APPEND flag when passed a path, however passing an actual IO object. However, at the system call level, everything is the same. ref: http://github.com/evanphx/rubinius/issues/347
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/test_util.rb | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/test/unit/test_util.rb b/test/unit/test_util.rb index b267179..377f6b8 100644 --- a/test/unit/test_util.rb +++ b/test/unit/test_util.rb @@ -8,26 +8,29 @@ class TestUtil < Test::Unit::TestCase EXPECT_FLAGS = File::WRONLY | File::APPEND def test_reopen_logs_noop tmp = Tempfile.new('') - tmp.reopen(tmp.path, 'a') - tmp.sync = true - ext = tmp.external_encoding rescue nil - int = tmp.internal_encoding rescue nil - before = tmp.stat.inspect + fp = File.open(tmp.path, 'ab') + fp.sync = true + ext = fp.external_encoding rescue nil + int = fp.internal_encoding rescue nil + before = fp.stat.inspect Unicorn::Util.reopen_logs - assert_equal before, File.stat(tmp.path).inspect - assert_equal ext, (tmp.external_encoding rescue nil) - assert_equal int, (tmp.internal_encoding rescue nil) + assert_equal before, File.stat(fp.path).inspect + assert_equal ext, (fp.external_encoding rescue nil) + assert_equal int, (fp.internal_encoding rescue nil) + assert_equal(EXPECT_FLAGS, EXPECT_FLAGS & fp.fcntl(Fcntl::F_GETFL)) assert_nothing_raised { tmp.close! } + assert_nothing_raised { fp.close } end def test_reopen_logs_renamed tmp = Tempfile.new('') tmp_path = tmp.path.freeze - tmp.reopen(tmp_path, 'a') - tmp.sync = true - ext = tmp.external_encoding rescue nil - int = tmp.internal_encoding rescue nil - before = tmp.stat.inspect + fp = File.open(tmp_path, 'ab') + fp.sync = true + + ext = fp.external_encoding rescue nil + int = fp.internal_encoding rescue nil + before = fp.stat.inspect to = Tempfile.new('') File.rename(tmp_path, to.path) assert ! File.exist?(tmp_path) @@ -35,13 +38,14 @@ class TestUtil < Test::Unit::TestCase assert_equal tmp_path, tmp.path assert File.exist?(tmp_path) assert before != File.stat(tmp_path).inspect - assert_equal tmp.stat.inspect, File.stat(tmp_path).inspect - assert_equal ext, (tmp.external_encoding rescue nil) - assert_equal int, (tmp.internal_encoding rescue nil) - assert_equal(EXPECT_FLAGS, EXPECT_FLAGS & tmp.fcntl(Fcntl::F_GETFL)) - assert tmp.sync + assert_equal fp.stat.inspect, File.stat(tmp_path).inspect + assert_equal ext, (fp.external_encoding rescue nil) + assert_equal int, (fp.internal_encoding rescue nil) + assert_equal(EXPECT_FLAGS, EXPECT_FLAGS & fp.fcntl(Fcntl::F_GETFL)) + assert fp.sync assert_nothing_raised { tmp.close! } assert_nothing_raised { to.close! } + assert_nothing_raised { fp.close } end def test_reopen_logs_renamed_with_encoding |