Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Fixes #2693

Merged
merged 1 commit into from Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 26 additions & 5 deletions test/helper.rb
Expand Up @@ -27,6 +27,21 @@
require "puma"
require "puma/detect"

# used in various ssl test files, see test_puma_server_ssl.rb and
# test_puma_localhost_authority.rb
if Puma::HAS_SSL
require "puma/events"
class SSLEventsHelper < ::Puma::Events
attr_accessor :addr, :cert, :error

def ssl_error(error, ssl_socket)
self.error = error
self.addr = ssl_socket.peeraddr.last rescue "<unknown>"
self.cert = ssl_socket.peercert
end
end
end

# 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)
Expand Down Expand Up @@ -171,8 +186,14 @@ def full_name
unless $debugging_hold
out = $debugging_info.strip
unless out.empty?
puts "", " Debugging Info".rjust(75, '-'),
out, '-' * 75, ""
dash = "\u2500"
wid = ENV['GITHUB_ACTIONS'] ? 88 : 90
txt = " Debugging Info #{dash * 2}".rjust wid, dash
if ENV['GITHUB_ACTIONS']
puts "", "##[group]#{txt}", out, dash * wid, '', '::[endgroup]'
else
puts "", txt, out, dash * wid, ''
end
end
end
end
Expand All @@ -198,9 +219,9 @@ def aggregated_results(io)
hsh_s.each { |k,v|
io.puts " #{k} #{dash * 2}".rjust 90, dash
hsh_1 = v.group_by { |i| i.first.first }
hsh_1.each { |k,v|
io.puts " #{k[/\/test\/(.*)/,1]}"
v.each { |item|
hsh_1.each { |k1,v1|
io.puts " #{k1[/\/test\/(.*)/,1]}"
v1.each { |item|
num += 1
io.puts format(" %3s %-5s #{item[1]} #{item[2]}", "#{num})", ":#{item[0][1]}")
}
Expand Down
11 changes: 0 additions & 11 deletions test/test_puma_localhost_authority.rb
Expand Up @@ -7,19 +7,8 @@

if ::Puma::HAS_SSL && !Puma::IS_JRUBY
require "puma/minissl"
require "puma/events"
require "net/http"

class SSLEventsHelper < ::Puma::Events
attr_accessor :addr, :cert, :error

def ssl_error(error, ssl_socket)
self.error = error
self.addr = ssl_socket.peeraddr.last rescue "<unknown>"
self.cert = ssl_socket.peercert
end
end

# net/http (loaded in helper) does not necessarily load OpenSSL
require "openssl" unless Object.const_defined? :OpenSSL
end
Expand Down
13 changes: 1 addition & 12 deletions test/test_puma_server_ssl.rb
Expand Up @@ -6,19 +6,8 @@

if ::Puma::HAS_SSL
require "puma/minissl"
require "puma/events"
require "net/http"

class SSLEventsHelper < ::Puma::Events
attr_accessor :addr, :cert, :error

def ssl_error(error, ssl_socket)
self.error = error
self.addr = ssl_socket.peeraddr.last rescue "<unknown>"
self.cert = ssl_socket.peercert
end
end

# net/http (loaded in helper) does not necessarily load OpenSSL
require "openssl" unless Object.const_defined? :OpenSSL
if Puma::IS_JRUBY
Expand Down Expand Up @@ -217,7 +206,7 @@ def test_http_rejection
tcp = Thread.new do
req_http = Net::HTTP::Get.new "/", {}
# Net::ReadTimeout - TruffleRuby
assert_raises(Errno::ECONNREFUSED, EOFError, Net::ReadTimeout) do
assert_raises(Errno::ECONNREFUSED, EOFError, Net::ReadTimeout, Net::OpenTimeout) do
http.start.request(req_http) { |rep| body_http = rep.body }
end
end
Expand Down