1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

run tests with bundler since that is what our users run (#1317)

This commit is contained in:
Michael Grosser 2017-06-09 05:20:03 -07:00 committed by Nate Berkopec
parent 2cb2357d39
commit 0886aef3d0
5 changed files with 25 additions and 5 deletions

1
.gitignore vendored
View file

@ -12,6 +12,7 @@ tmp
t/
.rbx/
Gemfile.lock
gemfiles/2.1-Gemfile.lock
.idea/
/test/test_puma.state
/test/test_server.sock

View file

@ -1,5 +1,7 @@
source "https://rubygems.org"
gemspec path: ".."
gem "hoe"
gem "hoe-git"
gem "hoe-ignore"

View file

@ -163,7 +163,16 @@ module Puma
# Run the server. This blocks until the server is stopped
def run
previous_env = (defined?(Bundler) ? Bundler::ORIGINAL_ENV : ENV.to_h)
previous_env =
if defined?(Bundler)
env = Bundler::ORIGINAL_ENV
# add -rbundler/setup so we load from Gemfile when restarting
bundle = "-rbundler/setup"
env["RUBYOPT"] = [env["RUBYOPT"], bundle].join(" ") unless env["RUBYOPT"].include?(bundle)
env
else
ENV.to_h
end
@config.clamp
@ -225,8 +234,8 @@ module Puma
else
redirects = {:close_others => true}
@binder.listeners.each_with_index do |(l, io), i|
ENV["PUMA_INHERIT_#{i}"] = "#{io.to_i}:#{l}"
redirects[io.to_i] = io.to_i
ENV["PUMA_INHERIT_#{i}"] = "#{io.to_i}:#{l}"
redirects[io.to_i] = io.to_i
end
argv = restart_args

View file

@ -36,9 +36,13 @@ def hit(uris)
end
module TimeoutEveryTestCase
# our own subclass so we never confused different timeouts
class TestTookTooLong < Timeout::Error
end
def run(*)
if ENV['CI']
::Timeout.timeout(Puma.jruby? ? 120 : 30) { super }
::Timeout.timeout(Puma.jruby? ? 120 : 30, TestTookTooLong) { super }
else
super # we want to be able to use debugger
end

View file

@ -41,7 +41,11 @@ class TestIntegration < Minitest::Test
end
def server(argv)
cmd = "#{Gem.ruby} -Ilib bin/puma -b tcp://127.0.0.1:#{@tcp_port} #{argv}"
# when we were started with bundler all load-paths and bin-paths are setup correctly
# this is what 9X% of users run, so it is what we should test
# the other case is solely for package builders or testing 1-off cases where the system puma is used
base = (defined?(Bundler) ? "bundle exec puma" : "#{Gem.ruby} -Ilib bin/puma")
cmd = "#{base} -b tcp://127.0.0.1:#{@tcp_port} #{argv}"
@server = IO.popen(cmd, "r")
wait_for_server_to_boot