Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1893 from seven1m/master
Preserve BUNDLE_GEMFILE and add a test for it
- Loading branch information
Showing
7 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Gemfile.bundle_env_preservation_test.lock |
1 change: 1 addition & 0 deletions
1
test/bundle_preservation_test/Gemfile.bundle_env_preservation_test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gem 'puma', path: '../..' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
run lambda { |env| [200, {'Content-Type'=>'text/plain'}, [ENV['BUNDLE_GEMFILE'].inspect]] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require_relative "helper" | ||
require_relative "helpers/integration" | ||
|
||
class TestPreserveBundlerEnv < TestIntegration | ||
def setup | ||
skip NO_FORK_MSG unless HAS_FORK | ||
super | ||
end | ||
|
||
# It does not wipe out BUNDLE_GEMFILE et al | ||
def test_usr2_restart_preserves_bundler_environment | ||
skip_unless_signal_exist? :USR2 | ||
|
||
@tcp_port = UniquePort.call | ||
env = { | ||
# Intentionally set this to something we wish to keep intact on restarts | ||
"BUNDLE_GEMFILE" => "Gemfile.bundle_env_preservation_test", | ||
# Don't allow our (rake test's) original env to interfere with the child process | ||
"BUNDLER_ORIG_BUNDLE_GEMFILE" => nil | ||
} | ||
# Must use `bundle exec puma` here, because otherwise Bundler may not be defined, which is required to trigger the bug | ||
cmd = "bundle exec puma -q -w 1 --prune-bundler -b tcp://#{HOST}:#{@tcp_port}" | ||
Dir.chdir(File.expand_path("bundle_preservation_test", __dir__)) do | ||
@server = IO.popen(env, cmd.split, "r") | ||
end | ||
wait_for_server_to_boot | ||
@pid = @server.pid | ||
connection = connect | ||
initial_reply = read_body(connection) | ||
assert_match("Gemfile.bundle_env_preservation_test", initial_reply) | ||
restart_server connection | ||
new_reply = read_body(connection) | ||
assert_match("Gemfile.bundle_env_preservation_test", new_reply) | ||
end | ||
end |