1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/test/helper.rb
Eugene Kenny 342661f05e Use Ruby 2.2.9 on Travis again (#1552)
The test failures we saw after upgrading last time were caused by the
stopgap_13632 gem not being activated on the new version.
2018-04-02 08:03:19 -06:00

82 lines
1.7 KiB
Ruby

# Copyright (c) 2011 Evan Phoenix
# Copyright (c) 2005 Zed A. Shaw
if %w(2.2.7 2.2.8 2.2.9 2.3.4 2.4.1).include? RUBY_VERSION
begin
require 'stopgap_13632'
rescue LoadError
end
end
begin
require "bundler/setup"
rescue LoadError
warn "Failed to load bundler ... this should only happen during package building"
end
require "net/http"
require "timeout"
require "minitest/autorun"
require "minitest/pride"
$LOAD_PATH << File.expand_path("../../lib", __FILE__)
Thread.abort_on_exception = true
require "puma"
require "puma/events"
require "puma/detect"
# 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)
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
end
end
module UniquePort
@port = 3211
def self.call
@port += 1
@port
end
end
module TimeoutEveryTestCase
# our own subclass so we never confused different timeouts
class TestTookTooLong < Timeout::Error
end
def run(*)
::Timeout.timeout(Puma.jruby? ? 120 : 60, TestTookTooLong) { super }
end
end
if ENV['CI']
Minitest::Test.prepend TimeoutEveryTestCase
require 'minitest/retry'
Minitest::Retry.use!
end
module SkipTestsBasedOnRubyEngine
def skip_on_jruby
skip "Skipped on JRuby" if Puma.jruby?
end
def skip_on_appveyor
skip "Skipped on Appveyor" if ENV["APPVEYOR"]
end
end
Minitest::Test.include SkipTestsBasedOnRubyEngine