-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prevent booting with rack 3 * Move with_unbundled_env to integration helpers * Version restriction test environment * Allow skipping the wait period with the cli_server helper * Test for the rack version restriction * Fixup & Rename test file * Minor puma.rb and rack/version_restriction.rb changes --------- Co-authored-by: MSP-Greg <Greg.mpls@gmail.com>
- Loading branch information
Showing
7 changed files
with
83 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
begin | ||
begin | ||
# rack/version exists in Rack 2.2.0 and later, compatible with Ruby 2.3 and later | ||
# we prefer to not load Rack | ||
require 'rack/version' | ||
rescue LoadError | ||
require 'rack' | ||
end | ||
|
||
# Rack.release is needed for Rack v1, Rack::RELEASE was added in v2 | ||
if Gem::Version.new(Rack.release) >= Gem::Version.new("3.0.0") | ||
raise StandardError.new "Puma 5 is not compatible with Rack 3, please upgrade to Puma 6 or higher." | ||
end | ||
rescue LoadError | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "https://rubygems.org" | ||
|
||
gem 'rack', '>= 3.0.0' | ||
gem 'puma', path: '../..' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
run lambda { |env| [200, {"Content-Type" => "text/plain"}, ["Hello World"]] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require_relative "helper" | ||
require_relative "helpers/integration" | ||
|
||
class TestRackVersionRestriction < TestIntegration | ||
class PumaBooted < Timeout::Error; end | ||
|
||
def setup | ||
# Rack 3 minimum Ruby version is 2.4 | ||
skip if !::Puma::IS_MRI || RUBY_VERSION < '2.4' | ||
super | ||
end | ||
|
||
def teardown | ||
return if skipped? | ||
FileUtils.rm_rf ["#{workdir}/vendor", "#{workdir}/Gemfile.lock"] | ||
begin | ||
# KILL works with all OS's | ||
Process.kill(:KILL, @server.pid) if @server | ||
rescue Errno::ESRCH | ||
end | ||
end | ||
|
||
def test_prevent_booting_with_rack_3 | ||
msg = "Puma 5 is not compatible with Rack 3" | ||
puma_crashed = false | ||
|
||
Dir.chdir(workdir) do | ||
with_unbundled_env do | ||
silent_and_checked_system_command("bundle config --local path vendor/bundle") | ||
silent_and_checked_system_command("bundle install") | ||
Timeout.timeout(5, PumaBooted) do | ||
cli_server './config.ru', merge_err: true, skip_waiting: true | ||
sleep 0.1 until puma_crashed = @server.gets[msg] | ||
end | ||
end | ||
end | ||
|
||
rescue PumaBooted | ||
ensure | ||
assert puma_crashed, "Puma was expected to crash on boot, but it didn't! " | ||
end | ||
|
||
private | ||
|
||
def workdir | ||
File.expand_path("bundle_rack_3", __dir__) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters