From a367e73231c693b1c61a6d352055cb98962dce83 Mon Sep 17 00:00:00 2001 From: Jeremy Daer Date: Sat, 3 Oct 2015 20:39:49 -0700 Subject: [PATCH] CGI/FastCGI tests: Consolidate lighttpd detection and warnings --- test/helper.rb | 10 ++++++---- test/spec_cgi.rb | 10 ++++------ test/spec_fastcgi.rb | 14 ++++---------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index 46f6556f1..8a6c45357 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -5,7 +5,7 @@ class TestCase if `which lighttpd` && !$?.success? begin # Keep this first. - PID = fork { + LIGHTTPD_PID = fork { ENV['RACK_ENV'] = 'deployment' ENV['RUBYLIB'] = [ ::File.expand_path('../../lib', __FILE__), @@ -17,13 +17,15 @@ class TestCase end } rescue NotImplementedError - warn "Kernel#fork unsupported. Skipping CGI and FastCGI tests." + warn "Your Ruby doesn't support Kernel#fork. Skipping Rack::Handler::CGI and ::FastCGI tests." else Minitest.after_run do - Process.kill 15, PID - Process.wait(PID) + Process.kill 15, LIGHTTPD_PID + Process.wait LIGHTTPD_PID end end + else + warn "Lighttpd isn't installed. Skipping Rack::Handler::CGI and FastCGI tests. Install lighttpd to run them." end end end diff --git a/test/spec_cgi.rb b/test/spec_cgi.rb index b89ed9af9..77020c2f6 100644 --- a/test/spec_cgi.rb +++ b/test/spec_cgi.rb @@ -1,5 +1,7 @@ require 'helper' -begin + +if defined? LIGHTTPD_PID + require File.expand_path('../testrequest', __FILE__) require 'rack/handler/cgi' @@ -79,8 +81,4 @@ end end -rescue RuntimeError - $stderr.puts "Skipping Rack::Handler::CGI tests (lighttpd is required). Install lighttpd and try again." -rescue NotImplementedError - $stderr.puts "Your Ruby implemenation or platform does not support fork. Skipping Rack::Handler::CGI tests." -end +end # if defined? LIGHTTPD_PID diff --git a/test/spec_fastcgi.rb b/test/spec_fastcgi.rb index ef7c3c3f1..5a48327b1 100644 --- a/test/spec_fastcgi.rb +++ b/test/spec_fastcgi.rb @@ -1,5 +1,7 @@ require 'helper' -begin + +if defined? LIGHTTPD_PID + require File.expand_path('../testrequest', __FILE__) require 'rack/handler/fastcgi' @@ -11,10 +13,6 @@ @port = 9203 end - if `which lighttpd` && !$?.success? - raise "lighttpd not found" - end - it "respond" do sleep 1 GET("/test") @@ -84,8 +82,4 @@ end end -rescue RuntimeError - $stderr.puts "Skipping Rack::Handler::FastCGI tests (lighttpd is required). Install lighttpd and try again." -rescue LoadError - $stderr.puts "Skipping Rack::Handler::FastCGI tests (FCGI is required). `gem install fcgi` and try again." -end +end # if defined? LIGHTTPD_PID