mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Formula: use opt_prefix for service helpers
This commit is contained in:
parent
5ec335188f
commit
869b0ea519
@ -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,7 +701,16 @@ describe Formula do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#service" do
|
describe "#service" do
|
||||||
|
specify "no service defined" do
|
||||||
|
f = formula do
|
||||||
|
url "https://brew.sh/test-1.0.tbz"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(f.service).to eq(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
specify "service complicated" do
|
||||||
f = formula do
|
f = formula do
|
||||||
url "https://brew.sh/test-1.0.tbz"
|
url "https://brew.sh/test-1.0.tbz"
|
||||||
end
|
end
|
||||||
@ -728,6 +737,18 @@ describe Formula do
|
|||||||
expect(f.service).not_to eq(nil)
|
expect(f.service).not_to eq(nil)
|
||||||
end
|
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
|
||||||
|
|
||||||
specify "dependencies" do
|
specify "dependencies" do
|
||||||
f1 = formula "f1" do
|
f1 = formula "f1" do
|
||||||
url "f1-1.0"
|
url "f1-1.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user