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.
 | 
			
		||||
  sig { returns(Pathname) }
 | 
			
		||||
  def plist_path
 | 
			
		||||
    prefix/"#{plist_name}.plist"
 | 
			
		||||
    opt_prefix/"#{plist_name}.plist"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # The generated systemd {.service} file path.
 | 
			
		||||
  sig { returns(Pathname) }
 | 
			
		||||
  def systemd_service_path
 | 
			
		||||
    prefix/"#{service_name}.service"
 | 
			
		||||
    opt_prefix/"#{service_name}.service"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # The service specification of the software.
 | 
			
		||||
 | 
			
		||||
@ -223,7 +223,7 @@ describe FormulaInstaller do
 | 
			
		||||
    it "works if plist is set" do
 | 
			
		||||
      formula = Testball.new
 | 
			
		||||
      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_path).and_call_original
 | 
			
		||||
@ -241,7 +241,7 @@ describe FormulaInstaller do
 | 
			
		||||
      plist_path = formula.plist_path
 | 
			
		||||
      service_path = formula.systemd_service_path
 | 
			
		||||
      service = Homebrew::Service.new(formula)
 | 
			
		||||
      formula.prefix.mkpath
 | 
			
		||||
      formula.opt_prefix.mkpath
 | 
			
		||||
 | 
			
		||||
      expect(formula).to receive(:plist).and_return(nil)
 | 
			
		||||
      expect(formula).to receive(:service?).exactly(3).and_return(true)
 | 
			
		||||
@ -264,7 +264,7 @@ describe FormulaInstaller do
 | 
			
		||||
    it "returns without definition" do
 | 
			
		||||
      formula = Testball.new
 | 
			
		||||
      path = formula.plist_path
 | 
			
		||||
      formula.prefix.mkpath
 | 
			
		||||
      formula.opt_prefix.mkpath
 | 
			
		||||
 | 
			
		||||
      expect(formula).to receive(:plist).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
 | 
			
		||||
      formula = Testball.new
 | 
			
		||||
      path = formula.plist_path
 | 
			
		||||
      formula.prefix.mkpath
 | 
			
		||||
      formula.opt_prefix.mkpath
 | 
			
		||||
 | 
			
		||||
      expect(formula).to receive(:plist).and_return("plist")
 | 
			
		||||
      expect(formula).to receive(:service?).and_return(true)
 | 
			
		||||
 | 
			
		||||
@ -701,7 +701,16 @@ describe Formula do
 | 
			
		||||
    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
 | 
			
		||||
        url "https://brew.sh/test-1.0.tbz"
 | 
			
		||||
      end
 | 
			
		||||
@ -728,6 +737,18 @@ describe Formula do
 | 
			
		||||
      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
 | 
			
		||||
 | 
			
		||||
  specify "dependencies" do
 | 
			
		||||
    f1 = formula "f1" do
 | 
			
		||||
      url "f1-1.0"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user