about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-06-07 04:07:16 +0000
committerEric Wong <e@80x24.org>2016-06-07 04:07:37 +0000
commit6c2531dd6fca28d24dc521ee6fedc4dc11e54e04 (patch)
tree7a9ccc12ceb06afa1e7988702630a845da99564e
parent8bd2ce70d04414d147639ed2e28ac5a40f78595a (diff)
downloadyahns-6c2531dd6fca28d24dc521ee6fedc4dc11e54e04.tar.gz
We can force output buffer files to a directory of our
choosing to avoid being confused by temporary files
from other tests polluting the process we care about.
-rw-r--r--test/test_proxy_pass_no_buffering.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/test/test_proxy_pass_no_buffering.rb b/test/test_proxy_pass_no_buffering.rb
index b2c8b48..c60ccad 100644
--- a/test/test_proxy_pass_no_buffering.rb
+++ b/test/test_proxy_pass_no_buffering.rb
@@ -35,11 +35,13 @@ class TestProxyPassNoBuffering < Testcase
     server_helper_setup
     skip "kcar missing yahns/proxy_pass" unless defined?(Kcar)
     require 'yahns/proxy_pass'
+    @tmpdir = yahns_mktmpdir
   end
 
   def teardown
     @srv2.close if defined?(@srv2) && !@srv2.closed?
     server_helper_teardown
+    FileUtils.rm_rf(@tmpdir) if defined?(@tmpdir)
   end
 
   def check_headers(io)
@@ -55,11 +57,15 @@ class TestProxyPassNoBuffering < Testcase
     host2, port2 = @srv2.addr[3], @srv2.addr[1]
     pxp = Yahns::ProxyPass.new("http://#{host2}:#{port2}",
                                proxy_buffering: false)
+    tmpdir = @tmpdir
     pid = mkserver(cfg) do
       ObjectSpace.each_object(Yahns::TmpIO) { |io| io.close unless io.closed? }
       @srv2.close
       cfg.instance_eval do
-        app(:rack, pxp) { listen "#{host}:#{port}" }
+        app(:rack, pxp) do
+          listen "#{host}:#{port}"
+          output_buffering true, tmpdir: tmpdir
+        end
         stderr_path err.path
       end
     end
@@ -85,10 +91,11 @@ class TestProxyPassNoBuffering < Testcase
       sleep 0.1
       # ensure no files get created
       if RUBY_PLATFORM =~ /\blinux\b/ && `which lsof 2>/dev/null`.size >= 4
+        qtmpdir = Regexp.quote("#@tmpdir/")
         deleted1 = `lsof -p #{pid}`.split("\n")
-        deleted1 = deleted1.grep(/\bREG\b.* \(deleted\)/)
+        deleted1 = deleted1.grep(/\bREG\b.*#{qtmpdir}.* \(deleted\)/)
         deleted2 = `lsof -p #{pid2}`.split("\n")
-        deleted2 = deleted2.grep(/\bREG\b.* \(deleted\)/)
+        deleted2 = deleted2.grep(/\bREG\b.*#{qtmpdir}.* \(deleted\)/)
         [ deleted1, deleted2 ].each do |ary|
           ary.delete_if { |x| x =~ /\.(?:err|out) \(deleted\)/ }
         end