From 18191832714aaf77cb23b116de21711b5cfd652b Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Sat, 3 Jun 2017 07:59:30 -0700 Subject: [PATCH] run tests with bundler since that is what our users run --- lib/puma/launcher.rb | 12 +++++++++++- test/helper.rb | 6 +++++- test/test_integration.rb | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/puma/launcher.rb b/lib/puma/launcher.rb index dec770cd8f..2da9a49534 100644 --- a/lib/puma/launcher.rb +++ b/lib/puma/launcher.rb @@ -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 diff --git a/test/helper.rb b/test/helper.rb index 3fa2738dca..ec2717551c 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -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 diff --git a/test/test_integration.rb b/test/test_integration.rb index 0de25f5e1c..e443366b1f 100644 --- a/test/test_integration.rb +++ b/test/test_integration.rb @@ -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