Skip to content

Commit

Permalink
CGI/FastCGI tests: Consolidate lighttpd detection and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Oct 4, 2015
1 parent 3096a32 commit a367e73
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
10 changes: 6 additions & 4 deletions test/helper.rb
Expand Up @@ -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__),
Expand All @@ -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
10 changes: 4 additions & 6 deletions 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'

Expand Down Expand Up @@ -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
14 changes: 4 additions & 10 deletions 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'

Expand All @@ -11,10 +13,6 @@
@port = 9203
end

if `which lighttpd` && !$?.success?
raise "lighttpd not found"
end

it "respond" do
sleep 1
GET("/test")
Expand Down Expand Up @@ -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

0 comments on commit a367e73

Please sign in to comment.