Skip to content

Commit

Permalink
run tests with bundler since that is what our users run (#1317)
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser authored and nateberkopec committed Jun 9, 2017
1 parent 2cb2357 commit 0886aef
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@ tmp
t/
.rbx/
Gemfile.lock
gemfiles/2.1-Gemfile.lock
.idea/
/test/test_puma.state
/test/test_server.sock
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/2.1-Gemfile
@@ -1,5 +1,7 @@
source "https://rubygems.org"

gemspec path: ".."

gem "hoe"
gem "hoe-git"
gem "hoe-ignore"
Expand Down
15 changes: 12 additions & 3 deletions lib/puma/launcher.rb
Expand Up @@ -163,7 +163,16 @@ def phased_restart

# 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)

This comment has been minimized.

Copy link
@bughit

bughit Jun 26, 2017

please see #1344

env
else
ENV.to_h
end

@config.clamp

Expand Down Expand Up @@ -225,8 +234,8 @@ def restart!
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
Expand Down
6 changes: 5 additions & 1 deletion test/helper.rb
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion test/test_integration.rb
Expand Up @@ -41,7 +41,11 @@ def teardown
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
Expand Down

0 comments on commit 0886aef

Please sign in to comment.