about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-07-19 16:48:12 -0700
committerEric Wong <normalperson@yhbt.net>2009-07-19 17:13:44 -0700
commit864a25c20b1b7d785cdff20f99e4246e7a7f9a93 (patch)
treecf455585de70a18102a66e478f5a732bef52c527 /test
parent86fd8957c7799368619aa8ce054b440716494a11 (diff)
downloadunicorn-864a25c20b1b7d785cdff20f99e4246e7a7f9a93.tar.gz
test/test_helper doesn't seem to be required correctly anymore,
since we know our own module/test names don't conflict, just
fix RUBYLIB to include $(test_prefix)

With test_util.rb, using #reopen with Tempfile objects seems
prone to the objects being closed.  Not completely sure what is
going on but I'll just sidestep around it since I've stopped
trusting Tempfile by now...
(cherry picked from commit 344b85ff28e160daa6563ab7c80b733abdeb874a)
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_util.rb58
1 files changed, 30 insertions, 28 deletions
diff --git a/test/unit/test_util.rb b/test/unit/test_util.rb
index 1616eac..032f0be 100644
--- a/test/unit/test_util.rb
+++ b/test/unit/test_util.rb
@@ -43,20 +43,21 @@ class TestUtil < Test::Unit::TestCase
     tmp = Tempfile.new(nil)
     tmp_path = tmp.path.dup.freeze
     Encoding.list.each { |encoding|
-      tmp.reopen(tmp_path, "a:#{encoding.to_s}")
-      tmp.sync = true
-      assert_equal encoding, tmp.external_encoding
-      assert_nil tmp.internal_encoding
-      File.unlink(tmp_path)
-      assert ! File.exist?(tmp_path)
-      Unicorn::Util.reopen_logs
-      assert_equal tmp_path, tmp.path
-      assert File.exist?(tmp_path)
-      assert_equal tmp.stat.inspect, File.stat(tmp_path).inspect
-      assert_equal encoding, tmp.external_encoding
-      assert_nil tmp.internal_encoding
-      assert_equal(EXPECT_FLAGS, EXPECT_FLAGS & tmp.fcntl(Fcntl::F_GETFL))
-      assert tmp.sync
+      File.open(tmp_path, "a:#{encoding.to_s}") { |fp|
+        fp.sync = true
+        assert_equal encoding, fp.external_encoding
+        assert_nil fp.internal_encoding
+        File.unlink(tmp_path)
+        assert ! File.exist?(tmp_path)
+        Unicorn::Util.reopen_logs
+        assert_equal tmp_path, fp.path
+        assert File.exist?(tmp_path)
+        assert_equal fp.stat.inspect, File.stat(tmp_path).inspect
+        assert_equal encoding, fp.external_encoding
+        assert_nil fp.internal_encoding
+        assert_equal(EXPECT_FLAGS, EXPECT_FLAGS & fp.fcntl(Fcntl::F_GETFL))
+        assert fp.sync
+      }
     }
   end if STDIN.respond_to?(:external_encoding)
 
@@ -66,20 +67,21 @@ class TestUtil < Test::Unit::TestCase
     Encoding.list.each { |ext|
       Encoding.list.each { |int|
         next if ext == int
-        tmp.reopen(tmp_path, "a:#{ext.to_s}:#{int.to_s}")
-        tmp.sync = true
-        assert_equal ext, tmp.external_encoding
-        assert_equal int, tmp.internal_encoding
-        File.unlink(tmp_path)
-        assert ! File.exist?(tmp_path)
-        Unicorn::Util.reopen_logs
-        assert_equal tmp_path, tmp.path
-        assert File.exist?(tmp_path)
-        assert_equal tmp.stat.inspect, File.stat(tmp_path).inspect
-        assert_equal ext, tmp.external_encoding
-        assert_equal int, tmp.internal_encoding
-        assert_equal(EXPECT_FLAGS, EXPECT_FLAGS & tmp.fcntl(Fcntl::F_GETFL))
-        assert tmp.sync
+        File.open(tmp_path, "a:#{ext.to_s}:#{int.to_s}") { |fp|
+          fp.sync = true
+          assert_equal ext, fp.external_encoding
+          assert_equal int, fp.internal_encoding
+          File.unlink(tmp_path)
+          assert ! File.exist?(tmp_path)
+          Unicorn::Util.reopen_logs
+          assert_equal tmp_path, fp.path
+          assert File.exist?(tmp_path)
+          assert_equal fp.stat.inspect, File.stat(tmp_path).inspect
+          assert_equal ext, fp.external_encoding
+          assert_equal int, fp.internal_encoding
+          assert_equal(EXPECT_FLAGS, EXPECT_FLAGS & fp.fcntl(Fcntl::F_GETFL))
+          assert fp.sync
+        }
       }
     }
   end if STDIN.respond_to?(:external_encoding)