Merge branch 'chore/formula/deprecate_plist_options' into deprecate-disable-remove
This commit is contained in:
commit
a086fcd293
@ -1017,7 +1017,7 @@ class Formula
|
|||||||
# The generated launchd {.plist} file path.
|
# The generated launchd {.plist} file path.
|
||||||
sig { returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
def plist_path
|
def plist_path
|
||||||
# odeprecated "formula.plist_path", "formula.launchd_service_path"
|
odeprecated "formula.plist_path", "formula.launchd_service_path"
|
||||||
launchd_service_path
|
launchd_service_path
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3152,7 +3152,7 @@ class Formula
|
|||||||
#
|
#
|
||||||
# @deprecated Please use {Homebrew::Service.require_root} instead.
|
# @deprecated Please use {Homebrew::Service.require_root} instead.
|
||||||
def plist_options(options)
|
def plist_options(options)
|
||||||
# odeprecated "plist_options", "service.require_root"
|
odeprecated "plist_options", "service.require_root"
|
||||||
@plist_startup = options[:startup]
|
@plist_startup = options[:startup]
|
||||||
@plist_manual = options[:manual]
|
@plist_manual = options[:manual]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1051,9 +1051,9 @@ class FormulaInstaller
|
|||||||
|
|
||||||
return unless service
|
return unless service
|
||||||
|
|
||||||
plist_path = formula.plist_path
|
launchd_service_path = formula.launchd_service_path
|
||||||
plist_path.atomic_write(service)
|
launchd_service_path.atomic_write(service)
|
||||||
plist_path.chmod 0644
|
launchd_service_path.chmod 0644
|
||||||
log = formula.var/"log"
|
log = formula.var/"log"
|
||||||
log.mkpath if service.include? log.to_s
|
log.mkpath if service.include? log.to_s
|
||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
|
|||||||
@ -44,17 +44,6 @@ describe Caveats do
|
|||||||
expect(described_class.new(f).caveats).to include("provides a launchd plist which can only be used on macOS!")
|
expect(described_class.new(f).caveats).to include("provides a launchd plist which can only be used on macOS!")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints plist startup information when f.plist_startup is not nil" do
|
|
||||||
f = formula do
|
|
||||||
url "foo-1.0"
|
|
||||||
def plist
|
|
||||||
"plist_test.plist"
|
|
||||||
end
|
|
||||||
plist_options startup: true
|
|
||||||
end
|
|
||||||
expect(described_class.new(f).caveats).to include("startup")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "prints plist login information when f.plist_startup is nil" do
|
it "prints plist login information when f.plist_startup is nil" do
|
||||||
f = formula do
|
f = formula do
|
||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
@ -65,39 +54,6 @@ describe Caveats do
|
|||||||
expect(described_class.new(f).caveats).to include("login")
|
expect(described_class.new(f).caveats).to include("login")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "gives information about restarting services after upgrade" do
|
|
||||||
f = formula do
|
|
||||||
url "foo-1.0"
|
|
||||||
def plist
|
|
||||||
"plist_test.plist"
|
|
||||||
end
|
|
||||||
plist_options startup: true
|
|
||||||
end
|
|
||||||
f_obj = described_class.new(f)
|
|
||||||
plist_path = mktmpdir/"plist"
|
|
||||||
FileUtils.touch plist_path
|
|
||||||
allow(f_obj).to receive(:plist_path).and_return(plist_path)
|
|
||||||
allow(Homebrew).to receive(:_system).and_return(true)
|
|
||||||
allow(Homebrew).to receive(:_system).with("/bin/launchctl list #{f.plist_name} &>/dev/null").and_return(true)
|
|
||||||
allow(plist_path).to receive(:symlink?).and_return(true)
|
|
||||||
expect(f_obj.caveats).to include("restart #{f.full_name}")
|
|
||||||
expect(f_obj.caveats).to include("sudo")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "gives information about plist_manual" do
|
|
||||||
f = formula do
|
|
||||||
url "foo-1.0"
|
|
||||||
def plist
|
|
||||||
"plist_test.plist"
|
|
||||||
end
|
|
||||||
plist_options manual: "foo"
|
|
||||||
end
|
|
||||||
caveats = described_class.new(f).caveats
|
|
||||||
|
|
||||||
expect(caveats).to include("background service")
|
|
||||||
expect(caveats).to include(f.plist_manual)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "gives information about service" do
|
it "gives information about service" do
|
||||||
f = formula do
|
f = formula do
|
||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
@ -141,7 +97,6 @@ describe Caveats do
|
|||||||
service do
|
service do
|
||||||
run [bin/"cmd"]
|
run [bin/"cmd"]
|
||||||
end
|
end
|
||||||
plist_options startup: true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
allow_any_instance_of(Object).to receive(:which).with("launchctl").and_return(nil)
|
allow_any_instance_of(Object).to receive(:which).with("launchctl").and_return(nil)
|
||||||
@ -149,13 +104,13 @@ describe Caveats do
|
|||||||
expect(described_class.new(f).caveats).to include("service which can only be used on macOS or systemd!")
|
expect(described_class.new(f).caveats).to include("service which can only be used on macOS or systemd!")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints service startup information when f.plist_startup is not nil" do
|
it "prints service startup information when service.require_root is true" do
|
||||||
f = formula do
|
f = formula do
|
||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
service do
|
service do
|
||||||
run [bin/"cmd"]
|
run [bin/"cmd"]
|
||||||
|
require_root true
|
||||||
end
|
end
|
||||||
plist_options startup: true
|
|
||||||
end
|
end
|
||||||
cmd = "#{HOMEBREW_CELLAR}/formula_name/1.0/bin/cmd"
|
cmd = "#{HOMEBREW_CELLAR}/formula_name/1.0/bin/cmd"
|
||||||
allow(Homebrew).to receive(:_system).and_return(true)
|
allow(Homebrew).to receive(:_system).and_return(true)
|
||||||
@ -176,21 +131,6 @@ describe Caveats do
|
|||||||
expect(described_class.new(f).caveats).to include("login")
|
expect(described_class.new(f).caveats).to include("login")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "gives information about plist_options restarting services after upgrade" do
|
|
||||||
f = formula do
|
|
||||||
url "foo-1.0"
|
|
||||||
service do
|
|
||||||
run [bin/"cmd"]
|
|
||||||
end
|
|
||||||
plist_options startup: true
|
|
||||||
end
|
|
||||||
cmd = "#{HOMEBREW_CELLAR}/formula_name/1.0/bin/cmd"
|
|
||||||
f_obj = described_class.new(f)
|
|
||||||
allow(Homebrew).to receive(:_system).and_return(true)
|
|
||||||
expect(Homebrew).to receive(:_system).with("ps aux | grep #{cmd}").and_return(true)
|
|
||||||
expect(f_obj.caveats).to include(" sudo brew services restart #{f.full_name}")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "gives information about require_root restarting services after upgrade" do
|
it "gives information about require_root restarting services after upgrade" do
|
||||||
f = formula do
|
f = formula do
|
||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
|
|||||||
@ -203,11 +203,11 @@ describe FormulaInstaller do
|
|||||||
describe "#install_service" do
|
describe "#install_service" do
|
||||||
it "works if plist is set" do
|
it "works if plist is set" do
|
||||||
formula = Testball.new
|
formula = Testball.new
|
||||||
path = formula.plist_path
|
path = formula.launchd_service_path
|
||||||
formula.opt_prefix.mkpath
|
formula.opt_prefix.mkpath
|
||||||
|
|
||||||
expect(formula).to receive(:plist).twice.and_return("PLIST")
|
expect(formula).to receive(:plist).twice.and_return("PLIST")
|
||||||
expect(formula).to receive(:plist_path).and_call_original
|
expect(formula).to receive(:launchd_service_path).and_call_original
|
||||||
|
|
||||||
installer = described_class.new(formula)
|
installer = described_class.new(formula)
|
||||||
expect {
|
expect {
|
||||||
@ -219,7 +219,7 @@ describe FormulaInstaller do
|
|||||||
|
|
||||||
it "works if service is set" do
|
it "works if service is set" do
|
||||||
formula = Testball.new
|
formula = Testball.new
|
||||||
plist_path = formula.plist_path
|
launchd_service_path = formula.launchd_service_path
|
||||||
service_path = formula.systemd_service_path
|
service_path = formula.systemd_service_path
|
||||||
service = Homebrew::Service.new(formula)
|
service = Homebrew::Service.new(formula)
|
||||||
formula.opt_prefix.mkpath
|
formula.opt_prefix.mkpath
|
||||||
@ -227,7 +227,7 @@ describe FormulaInstaller do
|
|||||||
expect(formula).to receive(:plist).and_return(nil)
|
expect(formula).to receive(:plist).and_return(nil)
|
||||||
expect(formula).to receive(:service?).exactly(3).and_return(true)
|
expect(formula).to receive(:service?).exactly(3).and_return(true)
|
||||||
expect(formula).to receive(:service).exactly(5).and_return(service)
|
expect(formula).to receive(:service).exactly(5).and_return(service)
|
||||||
expect(formula).to receive(:plist_path).and_call_original
|
expect(formula).to receive(:launchd_service_path).and_call_original
|
||||||
expect(formula).to receive(:systemd_service_path).and_call_original
|
expect(formula).to receive(:systemd_service_path).and_call_original
|
||||||
|
|
||||||
expect(service).to receive(:timed?).and_return(false)
|
expect(service).to receive(:timed?).and_return(false)
|
||||||
@ -240,13 +240,13 @@ describe FormulaInstaller do
|
|||||||
installer.install_service
|
installer.install_service
|
||||||
}.not_to output(/Error: Failed to install service files/).to_stderr
|
}.not_to output(/Error: Failed to install service files/).to_stderr
|
||||||
|
|
||||||
expect(plist_path).to exist
|
expect(launchd_service_path).to exist
|
||||||
expect(service_path).to exist
|
expect(service_path).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works if timed service is set" do
|
it "works if timed service is set" do
|
||||||
formula = Testball.new
|
formula = Testball.new
|
||||||
plist_path = formula.plist_path
|
launchd_service_path = formula.launchd_service_path
|
||||||
service_path = formula.systemd_service_path
|
service_path = formula.systemd_service_path
|
||||||
timer_path = formula.systemd_timer_path
|
timer_path = formula.systemd_timer_path
|
||||||
service = Homebrew::Service.new(formula)
|
service = Homebrew::Service.new(formula)
|
||||||
@ -255,7 +255,7 @@ describe FormulaInstaller do
|
|||||||
expect(formula).to receive(:plist).and_return(nil)
|
expect(formula).to receive(:plist).and_return(nil)
|
||||||
expect(formula).to receive(:service?).exactly(3).and_return(true)
|
expect(formula).to receive(:service?).exactly(3).and_return(true)
|
||||||
expect(formula).to receive(:service).exactly(6).and_return(service)
|
expect(formula).to receive(:service).exactly(6).and_return(service)
|
||||||
expect(formula).to receive(:plist_path).and_call_original
|
expect(formula).to receive(:launchd_service_path).and_call_original
|
||||||
expect(formula).to receive(:systemd_service_path).and_call_original
|
expect(formula).to receive(:systemd_service_path).and_call_original
|
||||||
expect(formula).to receive(:systemd_timer_path).and_call_original
|
expect(formula).to receive(:systemd_timer_path).and_call_original
|
||||||
|
|
||||||
@ -270,19 +270,19 @@ describe FormulaInstaller do
|
|||||||
installer.install_service
|
installer.install_service
|
||||||
}.not_to output(/Error: Failed to install service files/).to_stderr
|
}.not_to output(/Error: Failed to install service files/).to_stderr
|
||||||
|
|
||||||
expect(plist_path).to exist
|
expect(launchd_service_path).to exist
|
||||||
expect(service_path).to exist
|
expect(service_path).to exist
|
||||||
expect(timer_path).to exist
|
expect(timer_path).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns without definition" do
|
it "returns without definition" do
|
||||||
formula = Testball.new
|
formula = Testball.new
|
||||||
path = formula.plist_path
|
path = formula.launchd_service_path
|
||||||
formula.opt_prefix.mkpath
|
formula.opt_prefix.mkpath
|
||||||
|
|
||||||
expect(formula).to receive(:plist).and_return(nil)
|
expect(formula).to receive(:plist).and_return(nil)
|
||||||
expect(formula).to receive(:service?).exactly(3).and_return(nil)
|
expect(formula).to receive(:service?).exactly(3).and_return(nil)
|
||||||
expect(formula).not_to receive(:plist_path)
|
expect(formula).not_to receive(:launchd_service_path)
|
||||||
expect(formula).not_to receive(:to_systemd_unit)
|
expect(formula).not_to receive(:to_systemd_unit)
|
||||||
|
|
||||||
installer = described_class.new(formula)
|
installer = described_class.new(formula)
|
||||||
@ -295,13 +295,13 @@ describe FormulaInstaller do
|
|||||||
|
|
||||||
it "errors with duplicate definition" do
|
it "errors with duplicate definition" do
|
||||||
formula = Testball.new
|
formula = Testball.new
|
||||||
path = formula.plist_path
|
path = formula.launchd_service_path
|
||||||
formula.opt_prefix.mkpath
|
formula.opt_prefix.mkpath
|
||||||
|
|
||||||
expect(formula).to receive(:plist).and_return("plist")
|
expect(formula).to receive(:plist).and_return("plist")
|
||||||
expect(formula).to receive(:service?).and_return(true)
|
expect(formula).to receive(:service?).and_return(true)
|
||||||
expect(formula).not_to receive(:service)
|
expect(formula).not_to receive(:service)
|
||||||
expect(formula).not_to receive(:plist_path)
|
expect(formula).not_to receive(:launchd_service_path)
|
||||||
|
|
||||||
installer = described_class.new(formula)
|
installer = described_class.new(formula)
|
||||||
expect {
|
expect {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user