about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-02-27 13:55:21 -0800
committerEric Wong <normalperson@yhbt.net>2009-03-03 11:13:03 -0800
commit431e8fd9d2d3783de8bbcfb55ff314871bcb7fea (patch)
tree89900face7799a41f519758f5f430b8fbdf9a34d /test
parent528b30a9a3f2de1f0f44ef1a4ac65519a0770d58 (diff)
downloadunicorn-431e8fd9d2d3783de8bbcfb55ff314871bcb7fea.tar.gz
Hopefully this fixes some random test failures I've
been experiencing...
Diffstat (limited to 'test')
-rw-r--r--test/exec/test_exec.rb23
1 files changed, 16 insertions, 7 deletions
diff --git a/test/exec/test_exec.rb b/test/exec/test_exec.rb
index fb26195..b539b22 100644
--- a/test/exec/test_exec.rb
+++ b/test/exec/test_exec.rb
@@ -126,7 +126,7 @@ end # after_fork
     ucfg.syswrite("listeners %w(#{@addr}:#{@port})\n")
     ucfg.syswrite("pid %(#{pid_file})\n")
     ucfg.syswrite("logger Logger.new(%(#{@tmpdir}/log))\n")
-    pid = fork do
+    pid = xfork do
       redirect_test_io do
         exec($unicorn_bin, "-D", "-l#{@addr}:#{@port}", "-c#{ucfg.path}")
       end
@@ -192,7 +192,7 @@ end # after_fork
     ucfg = Tempfile.new('unicorn_test_config')
     ucfg.syswrite("pid %(#{pid_file})\n")
     ucfg.syswrite("logger Logger.new(%(#{@tmpdir}/log))\n")
-    pid = fork do
+    pid = xfork do
       redirect_test_io do
         exec($unicorn_bin, "-D", "-l#{@addr}:#{@port}", "-c#{ucfg.path}")
       end
@@ -251,7 +251,7 @@ end # after_fork
     # listeners = [ ... ]  => should _override_ command-line options
     ucfg = Tempfile.new('unicorn_test_config')
     ucfg.syswrite("listeners %w(#{@addr}:#{@port})\n")
-    pid = fork do
+    pid = xfork do
       redirect_test_io do
         exec($unicorn_bin, "-c#{ucfg.path}", "-l#{@addr}:#{port2}")
       end
@@ -267,7 +267,7 @@ end # after_fork
     File.open("config.ru", "wb") { |fp| fp.syswrite(HI) }
     ucfg = Tempfile.new('unicorn_test_config')
     ucfg.syswrite("listen '#{@addr}:#{@port}'\n")
-    pid = fork do
+    pid = xfork do
       redirect_test_io do
         exec($unicorn_bin, "-c#{ucfg.path}", "-l#{@addr}:#{port2}")
       end
@@ -284,7 +284,7 @@ end # after_fork
     File.open("config.ru", "wb") { |fp| fp.syswrite(HI) }
     ucfg = Tempfile.new('unicorn_test_config')
     ucfg.syswrite(HEAVY_CFG)
-    pid = fork do
+    pid = xfork do
       redirect_test_io do
         exec($unicorn_bin, "-c#{ucfg.path}", "-l#{@addr}:#{@port}")
       end
@@ -409,7 +409,7 @@ end # after_fork
     ucfg.close
 
     File.open("config.ru", "wb") { |fp| fp.syswrite(HI) }
-    pid = fork do
+    pid = xfork do
       redirect_test_io do
         exec($unicorn_bin, "-l#{@addr}:#{@port}",
              "-P#{pid_file}", "-c#{ucfg.path}")
@@ -470,7 +470,7 @@ end # after_fork
     ucfg.close
 
     File.open("config.ru", "wb") { |fp| fp.syswrite(HI) }
-    pid = fork do
+    pid = xfork do
       redirect_test_io do
         exec($unicorn_bin, "-D", "-l#{@addr}:#{@port}", "-c#{ucfg.path}")
       end
@@ -572,4 +572,13 @@ end # after_fork
       assert File.exist?(path), "path=#{path} exists"
     end
 
+    def xfork(&block)
+      fork do
+        ObjectSpace.each_object(Tempfile) do |tmp|
+          ObjectSpace.undefine_finalizer(tmp)
+        end
+        yield
+      end
+    end
+
 end if do_test