formula_installer: tweak req formula additions.
Rather than just checking if a requirement's dependency is installed or not check if the requirement was actually satisfied by a particular formula rather than e.g. just having a `default_formula` defined.
This commit is contained in:
parent
098ed84df4
commit
0cc9d93885
@ -415,7 +415,7 @@ class FormulaInstaller
|
|||||||
return true unless req.satisfied?
|
return true unless req.satisfied?
|
||||||
return false if req.run?
|
return false if req.run?
|
||||||
return true if build_bottle?
|
return true if build_bottle?
|
||||||
return true unless req_dependency.installed?
|
return true if req.satisfied_by_formula?
|
||||||
install_bottle_for?(dependent, build)
|
install_bottle_for?(dependent, build)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -125,6 +125,10 @@ class Requirement
|
|||||||
@formula || self.class.default_formula
|
@formula || self.class.default_formula
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def satisfied_by_formula?
|
||||||
|
!@formula.nil?
|
||||||
|
end
|
||||||
|
|
||||||
def to_dependency
|
def to_dependency
|
||||||
if formula =~ HOMEBREW_TAP_FORMULA_REGEX
|
if formula =~ HOMEBREW_TAP_FORMULA_REGEX
|
||||||
TapDependency.new(formula, tags, method(:modify_build_environment), name)
|
TapDependency.new(formula, tags, method(:modify_build_environment), name)
|
||||||
|
@ -134,4 +134,43 @@ describe FormulaInstaller do
|
|||||||
fi.check_install_sanity
|
fi.check_install_sanity
|
||||||
}.to raise_error(CannotInstallFormulaError)
|
}.to raise_error(CannotInstallFormulaError)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#install_requirement_formula?" do
|
||||||
|
before do
|
||||||
|
@requirement = Python3Requirement.new
|
||||||
|
allow(@requirement).to receive(:satisfied?).and_return(satisfied?)
|
||||||
|
allow(@requirement).to receive(:satisfied_by_formula?).and_return(satisfied_by_formula?)
|
||||||
|
allow_any_instance_of(Dependency).to receive(:installed?).and_return(installed?)
|
||||||
|
@dependent = formula do
|
||||||
|
url "foo"
|
||||||
|
version "0.1"
|
||||||
|
depends_on :python3
|
||||||
|
end
|
||||||
|
@build = BuildOptions.new [], []
|
||||||
|
@fi = FormulaInstaller.new(@dependent)
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { @fi.install_requirement_formula?(@requirement, @dependent, @build) }
|
||||||
|
|
||||||
|
context "it returns false when requirement is satisfied" do
|
||||||
|
let(:satisfied?) { true }
|
||||||
|
let(:satisfied_by_formula?) { false }
|
||||||
|
let(:installed?) { false }
|
||||||
|
it { is_expected.to be false }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "it returns true when requirement isn't satisfied" do
|
||||||
|
let(:satisfied?) { false }
|
||||||
|
let(:satisfied_by_formula?) { false }
|
||||||
|
let(:installed?) { false }
|
||||||
|
it { is_expected.to be true }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "it returns true when requirement is satisfied by a formula" do
|
||||||
|
let(:satisfied?) { true }
|
||||||
|
let(:satisfied_by_formula?) { true }
|
||||||
|
let(:installed?) { false }
|
||||||
|
it { is_expected.to be true }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user