mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
efb706daad
Since https://github.com/puma/puma/pull/1700, the default host is correctly used. So `localhost` is used instead of `0.0.0.0`. As a result, the log output on restart is changed, and the restart test fails on Puma 3.12.1. https://travis-ci.org/rails/rails/jobs/509239592#L2303-L2305 Specify binding explicitly to avoid being affected by Puma changes.
52 lines
1.2 KiB
Ruby
52 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "isolation/abstract_unit"
|
|
require "console_helpers"
|
|
require "rails/command"
|
|
require "rails/commands/server/server_command"
|
|
|
|
module ApplicationTests
|
|
class ServerTest < ActiveSupport::TestCase
|
|
include ActiveSupport::Testing::Isolation
|
|
include ConsoleHelpers
|
|
|
|
def setup
|
|
build_app
|
|
end
|
|
|
|
def teardown
|
|
teardown_app
|
|
end
|
|
|
|
test "restart rails server with custom pid file path" do
|
|
skip "PTY unavailable" unless available_pty?
|
|
|
|
File.open("#{app_path}/config/boot.rb", "w") do |f|
|
|
f.puts "ENV['BUNDLE_GEMFILE'] = '#{Bundler.default_gemfile}'"
|
|
f.puts "require 'bundler/setup'"
|
|
end
|
|
|
|
primary, replica = PTY.open
|
|
pid = nil
|
|
|
|
Bundler.with_original_env do
|
|
pid = Process.spawn("bin/rails server -b localhost -P tmp/dummy.pid", chdir: app_path, in: replica, out: replica, err: replica)
|
|
assert_output("Listening", primary)
|
|
|
|
rails("restart")
|
|
|
|
assert_output("Restarting", primary)
|
|
assert_output("tcp://localhost:3000", primary)
|
|
ensure
|
|
kill(pid) if pid
|
|
end
|
|
end
|
|
|
|
private
|
|
def kill(pid)
|
|
Process.kill("TERM", pid)
|
|
Process.wait(pid)
|
|
rescue Errno::ESRCH
|
|
end
|
|
end
|
|
end
|