Skip to content

Commit

Permalink
run tests with bundler since that is what our users run
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Jun 5, 2017
1 parent 2cb2357 commit 1819183
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
12 changes: 11 additions & 1 deletion lib/puma/launcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,17 @@ 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
env["RUBYOPT"] += [env["RUBYOPT"].to_s.split(" "), "-rbundler/setup"].uniq.compact.join(" ")
env
else
ENV.to_h
end

puts "ENV #{previous_env}"

@config.clamp

Expand Down
6 changes: 5 additions & 1 deletion test/helper.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 1819183

Please sign in to comment.