2011-09-23 23:46:33 -04:00
|
|
|
# Copyright (c) 2011 Evan Phoenix
|
2016-11-20 12:20:58 -05:00
|
|
|
# Copyright (c) 2005 Zed A. Shaw
|
2006-06-30 16:42:12 -04:00
|
|
|
|
2017-11-20 08:24:02 -05:00
|
|
|
if %w(2.2.7 2.2.8 2.3.4 2.4.1).include? RUBY_VERSION
|
|
|
|
begin
|
|
|
|
require 'stopgap_13632'
|
|
|
|
rescue LoadError
|
|
|
|
end
|
2017-08-16 18:07:15 -04:00
|
|
|
end
|
2017-07-19 14:22:36 -04:00
|
|
|
|
2017-02-16 11:54:03 -05:00
|
|
|
begin
|
|
|
|
require "bundler/setup"
|
|
|
|
rescue LoadError
|
2017-04-11 17:48:11 -04:00
|
|
|
warn "Failed to load bundler ... this should only happen during package building"
|
2017-02-16 11:54:03 -05:00
|
|
|
end
|
2017-03-08 10:35:18 -05:00
|
|
|
|
|
|
|
require "net/http"
|
|
|
|
require "timeout"
|
2016-11-22 10:05:49 -05:00
|
|
|
require "minitest/autorun"
|
|
|
|
require "minitest/pride"
|
2007-10-20 22:55:59 -04:00
|
|
|
|
2017-03-03 17:04:56 -05:00
|
|
|
$LOAD_PATH << File.expand_path("../../lib", __FILE__)
|
2017-06-04 08:48:04 -04:00
|
|
|
Thread.abort_on_exception = true
|
2017-03-03 17:04:56 -05:00
|
|
|
|
2017-04-11 17:48:11 -04:00
|
|
|
require "puma"
|
2017-09-22 16:44:21 -04:00
|
|
|
require "puma/events"
|
2017-04-11 17:48:11 -04:00
|
|
|
require "puma/detect"
|
|
|
|
|
2007-10-20 22:55:59 -04:00
|
|
|
# Either takes a string to do a get request against, or a tuple of [URI, HTTP] where
|
|
|
|
# HTTP is some kind of Net::HTTP request object (POST, HEAD, etc.)
|
|
|
|
def hit(uris)
|
2017-04-11 17:48:11 -04:00
|
|
|
uris.map do |u|
|
|
|
|
response =
|
|
|
|
if u.kind_of? String
|
|
|
|
Net::HTTP.get(URI.parse(u))
|
|
|
|
else
|
|
|
|
url = URI.parse(u[0])
|
|
|
|
Net::HTTP.new(url.host, url.port).start {|h| h.request(u[1]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
assert response, "Didn't get a response: #{u}"
|
|
|
|
response
|
2007-10-20 22:54:53 -04:00
|
|
|
end
|
2006-05-30 19:36:48 -04:00
|
|
|
end
|
2016-11-20 12:20:58 -05:00
|
|
|
|
|
|
|
module TimeoutEveryTestCase
|
2017-06-09 08:20:03 -04:00
|
|
|
# our own subclass so we never confused different timeouts
|
|
|
|
class TestTookTooLong < Timeout::Error
|
|
|
|
end
|
|
|
|
|
2016-11-22 10:05:49 -05:00
|
|
|
def run(*)
|
2017-08-16 18:07:15 -04:00
|
|
|
::Timeout.timeout(Puma.jruby? ? 120 : 60, TestTookTooLong) { super }
|
2016-11-20 12:20:58 -05:00
|
|
|
end
|
|
|
|
end
|
2016-11-21 09:40:56 -05:00
|
|
|
|
2017-08-16 18:07:15 -04:00
|
|
|
if ENV['CI']
|
|
|
|
Minitest::Test.prepend TimeoutEveryTestCase
|
|
|
|
|
|
|
|
require 'minitest/retry'
|
|
|
|
Minitest::Retry.use!
|
|
|
|
end
|
2016-11-22 10:05:49 -05:00
|
|
|
|
|
|
|
module SkipTestsBasedOnRubyEngine
|
|
|
|
def skip_on_jruby
|
|
|
|
skip "Skipped on JRuby" if Puma.jruby?
|
2016-11-21 09:40:56 -05:00
|
|
|
end
|
2017-07-27 14:18:58 -04:00
|
|
|
|
|
|
|
def skip_on_appveyor
|
|
|
|
skip "Skipped on Appveyor" if ENV["APPVEYOR"]
|
|
|
|
end
|
2016-11-21 09:40:56 -05:00
|
|
|
end
|
2016-11-22 10:05:49 -05:00
|
|
|
|
|
|
|
Minitest::Test.include SkipTestsBasedOnRubyEngine
|