mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Merge pull request #11772 from SMillerDev/fix/formula/opt_for_service_helpers
Formula: use opt_prefix for service helpers
This commit is contained in:
commit
4931c6cafc
@ -986,13 +986,13 @@ 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
|
||||||
prefix/"#{plist_name}.plist"
|
opt_prefix/"#{plist_name}.plist"
|
||||||
end
|
end
|
||||||
|
|
||||||
# The generated systemd {.service} file path.
|
# The generated systemd {.service} file path.
|
||||||
sig { returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
def systemd_service_path
|
def systemd_service_path
|
||||||
prefix/"#{service_name}.service"
|
opt_prefix/"#{service_name}.service"
|
||||||
end
|
end
|
||||||
|
|
||||||
# The service specification of the software.
|
# The service specification of the software.
|
||||||
|
@ -223,7 +223,7 @@ describe FormulaInstaller 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.plist_path
|
||||||
formula.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(:plist_path).and_call_original
|
||||||
@ -241,7 +241,7 @@ describe FormulaInstaller do
|
|||||||
plist_path = formula.plist_path
|
plist_path = formula.plist_path
|
||||||
service_path = formula.systemd_service_path
|
service_path = formula.systemd_service_path
|
||||||
service = Homebrew::Service.new(formula)
|
service = Homebrew::Service.new(formula)
|
||||||
formula.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(true)
|
expect(formula).to receive(:service?).exactly(3).and_return(true)
|
||||||
@ -264,7 +264,7 @@ describe FormulaInstaller do
|
|||||||
it "returns without definition" do
|
it "returns without definition" do
|
||||||
formula = Testball.new
|
formula = Testball.new
|
||||||
path = formula.plist_path
|
path = formula.plist_path
|
||||||
formula.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)
|
||||||
@ -282,7 +282,7 @@ 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.plist_path
|
||||||
formula.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)
|
||||||
|
@ -701,31 +701,52 @@ describe Formula do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#service" do
|
describe "#service" do
|
||||||
f = formula do
|
specify "no service defined" do
|
||||||
url "https://brew.sh/test-1.0.tbz"
|
f = formula do
|
||||||
end
|
url "https://brew.sh/test-1.0.tbz"
|
||||||
|
|
||||||
f.class.service do
|
|
||||||
run [opt_bin/"beanstalkd"]
|
|
||||||
run_type :immediate
|
|
||||||
error_log_path var/"log/beanstalkd.error.log"
|
|
||||||
log_path var/"log/beanstalkd.log"
|
|
||||||
working_dir var
|
|
||||||
keep_alive true
|
|
||||||
end
|
|
||||||
expect(f.service).not_to eq(nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
specify "service uses simple run" do
|
|
||||||
f = formula do
|
|
||||||
url "https://brew.sh/test-1.0.tbz"
|
|
||||||
service do
|
|
||||||
run opt_bin/"beanstalkd"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expect(f.service).to eq(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(f.service).not_to eq(nil)
|
specify "service complicated" do
|
||||||
|
f = formula do
|
||||||
|
url "https://brew.sh/test-1.0.tbz"
|
||||||
|
end
|
||||||
|
|
||||||
|
f.class.service do
|
||||||
|
run [opt_bin/"beanstalkd"]
|
||||||
|
run_type :immediate
|
||||||
|
error_log_path var/"log/beanstalkd.error.log"
|
||||||
|
log_path var/"log/beanstalkd.log"
|
||||||
|
working_dir var
|
||||||
|
keep_alive true
|
||||||
|
end
|
||||||
|
expect(f.service).not_to eq(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
specify "service uses simple run" do
|
||||||
|
f = formula do
|
||||||
|
url "https://brew.sh/test-1.0.tbz"
|
||||||
|
service do
|
||||||
|
run opt_bin/"beanstalkd"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(f.service).not_to eq(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
specify "service helpers return data" do
|
||||||
|
f = formula do
|
||||||
|
url "https://brew.sh/test-1.0.tbz"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(f.plist_name).to eq("homebrew.mxcl.formula_name")
|
||||||
|
expect(f.service_name).to eq("homebrew.formula_name")
|
||||||
|
expect(f.plist_path).to eq(HOMEBREW_PREFIX/"opt/formula_name/homebrew.mxcl.formula_name.plist")
|
||||||
|
expect(f.systemd_service_path).to eq(HOMEBREW_PREFIX/"opt/formula_name/homebrew.formula_name.service")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "dependencies" do
|
specify "dependencies" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user