aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/server_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/application/server_test.rb')
-rw-r--r--railties/test/application/server_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/railties/test/application/server_test.rb b/railties/test/application/server_test.rb
index 97b3b4f6b3..6db9a3b9e8 100644
--- a/railties/test/application/server_test.rb
+++ b/railties/test/application/server_test.rb
@@ -1,12 +1,14 @@
# 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
@@ -29,5 +31,31 @@ module ApplicationTests
log = File.read(Rails.application.config.paths["log"].first)
assert_match(/DEPRECATION WARNING: Use `Rails::Application` subclass to start the server is deprecated/, log)
end
+
+ test "restart rails server with custom pid file path" do
+ skip "PTY unavailable" unless available_pty?
+
+ master, slave = PTY.open
+ pid = nil
+
+ begin
+ pid = Process.spawn("#{app_path}/bin/rails server -P tmp/dummy.pid", in: slave, out: slave, err: slave)
+ assert_output("Listening", master)
+
+ Dir.chdir(app_path) { system("bin/rails restart") }
+
+ assert_output("Restarting", master)
+ assert_output("Inherited", master)
+ ensure
+ kill(pid) if pid
+ end
+ end
+
+ private
+ def kill(pid)
+ Process.kill("TERM", pid)
+ Process.wait(pid)
+ rescue Errno::ESRCH
+ end
end
end