mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Go back to using Bundler.with_original_env
Test that the environment is not lost when doing a restart by using the PATH env var as a canary. While we actually care about the BUNDLER_GEMFILE env var, that one is harder to set up in testing since it requires a full copy of Puma's Gemfile. This change also has the benefit of not only protecting the BUNDLE_GEMFILE var, but also the other variables that Bundler knows about.
This commit is contained in:
parent
56bbc2dc3a
commit
a3ed997855
3 changed files with 5 additions and 13 deletions
|
@ -277,10 +277,8 @@ module Puma
|
|||
|
||||
log '* Pruning Bundler environment'
|
||||
home = ENV['GEM_HOME']
|
||||
gemfile = ENV['BUNDLE_GEMFILE']
|
||||
Bundler.with_clean_env do
|
||||
Bundler.with_original_env do
|
||||
ENV['GEM_HOME'] = home
|
||||
ENV['BUNDLE_GEMFILE'] = gemfile
|
||||
ENV['PUMA_BUNDLER_PRUNED'] = '1'
|
||||
wild = File.expand_path(File.join(puma_lib_dir, "../bin/puma-wild"))
|
||||
args = [Gem.ruby, wild, '-I', dirs.join(':'), deps.join(',')] + @original_argv
|
||||
|
|
|
@ -1 +1 @@
|
|||
run lambda { |env| [200, {"Content-Type" => "text/plain"}, ["Hello BUNDLE_GEMFILE #{ENV["BUNDLE_GEMFILE"]}"]] }
|
||||
run lambda { |env| [200, {"Content-Type" => "text/plain"}, ["Hello PATH #{ENV["PATH"]}"]] }
|
||||
|
|
|
@ -240,15 +240,9 @@ class TestIntegration < Minitest::Test
|
|||
end
|
||||
|
||||
def test_restart_with_prune_bundler_keeps_bundle_gemfile_env
|
||||
gemfile_path = File.expand_path("../Gemfile", __dir__)
|
||||
duplicate_gemfile_path = gemfile_path + ".duplicate"
|
||||
FileUtils.cp(gemfile_path, gemfile_path + ".duplicate")
|
||||
initial_reply, new_reply = restart_server_and_listen("-q -w 2 --prune-bundler test/rackup/hello-bundler-env.ru", "BUNDLE_GEMFILE" => "Gemfile.duplicate")
|
||||
assert_match(/Hello BUNDLE_GEMFILE.*Gemfile\.duplicate/, initial_reply)
|
||||
assert_match(/Hello BUNDLE_GEMFILE.*Gemfile\.duplicate/, new_reply)
|
||||
ensure
|
||||
FileUtils.rm_f(duplicate_gemfile_path)
|
||||
FileUtils.rm_f(duplicate_gemfile_path + '.lock')
|
||||
initial_reply, new_reply = restart_server_and_listen("-q -w 2 --prune-bundler test/rackup/hello-bundler-env.ru", "PATH" => "hello-bundler:#{ENV["PATH"]}", "BUNDLER_ORIG_PATH" => nil)
|
||||
assert_match(/Hello PATH.*hello-bundler/, initial_reply)
|
||||
assert_match(/Hello PATH.*hello-bundler/, new_reply)
|
||||
end
|
||||
|
||||
def test_sigterm_closes_listeners_on_forked_servers
|
||||
|
|
Loading…
Add table
Reference in a new issue