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.
---
test/test_proxy_pass_no_buffering.rb | 13 ++++++++++---
1 file 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 @@ def setup
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) && [email protected]?
server_helper_teardown
+ FileUtils.rm_rf(@tmpdir) if defined?(@tmpdir)
end
def check_headers(io)
@@ -55,11 +57,15 @@ def test_proxy_pass_no_buffering
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 @@ def test_proxy_pass_no_buffering
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
--
unsubscribe: [email protected]
archive: https://yhbt.net/yahns-public/