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
|
|
|
|
2007-10-20 22:55:59 -04:00
|
|
|
require 'rubygems'
|
|
|
|
require 'test/unit'
|
|
|
|
require 'net/http'
|
|
|
|
require 'digest/sha1'
|
|
|
|
require 'uri'
|
|
|
|
require 'stringio'
|
|
|
|
|
2011-09-22 22:24:43 -04:00
|
|
|
require 'puma'
|
2016-11-21 09:40:56 -05: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)
|
|
|
|
results = []
|
|
|
|
uris.each do |u|
|
|
|
|
res = nil
|
|
|
|
|
|
|
|
if u.kind_of? String
|
|
|
|
res = Net::HTTP.get(URI.parse(u))
|
|
|
|
else
|
|
|
|
url = URI.parse(u[0])
|
|
|
|
res = Net::HTTP.new(url.host, url.port).start {|h| h.request(u[1]) }
|
2007-10-20 22:54:53 -04:00
|
|
|
end
|
2007-10-20 22:55:59 -04:00
|
|
|
|
|
|
|
assert res != nil, "Didn't get a response: #{u}"
|
|
|
|
results << res
|
2007-10-20 22:54:53 -04:00
|
|
|
end
|
2007-10-20 22:55:59 -04:00
|
|
|
|
|
|
|
return results
|
2006-05-30 19:36:48 -04:00
|
|
|
end
|
2016-11-20 12:20:58 -05:00
|
|
|
|
|
|
|
module TimeoutEveryTestCase
|
|
|
|
def run(*args)
|
|
|
|
if !!ENV['CI']
|
|
|
|
Timeout.timeout(60) { super }
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
Test::Unit::TestCase.prepend TimeoutEveryTestCase
|
2016-11-21 09:40:56 -05:00
|
|
|
|
|
|
|
module OmitTestsBasedOnRubyEngine
|
|
|
|
def omit_on_jruby
|
|
|
|
omit "Omitted on JRuby" if Puma.jruby?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
Test::Unit::TestCase.prepend OmitTestsBasedOnRubyEngine
|