aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2017-03-25 11:37:54 +0000
committerGitHub2017-03-25 11:37:54 +0000
commit17acb3a91cc399410ce6fa9b00280a7434fcd9a1 (patch)
tree5f86bbc9ccabfe1ee45a1aae0aecd77b86a73c4d
parent098ed84df4113f4a04a386765dd1c7537fa39f72 (diff)
parent0cc9d93885b7824e702156c50c46d22158b5a57f (diff)
downloadbrew-17acb3a91cc399410ce6fa9b00280a7434fcd9a1.tar.bz2
Merge pull request #2389 from MikeMcQuaid/formula-installer-requirement-satisfied-by-formula
formula_installer: tweak req formula additions.
-rw-r--r--Library/Homebrew/formula_installer.rb2
-rw-r--r--Library/Homebrew/requirement.rb4
-rw-r--r--Library/Homebrew/test/formula_installer_spec.rb39
3 files changed, 44 insertions, 1 deletions
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index fa46a30f4..017be51dc 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -415,7 +415,7 @@ class FormulaInstaller
return true unless req.satisfied?
return false if req.run?
return true if build_bottle?
- return true unless req_dependency.installed?
+ return true if req.satisfied_by_formula?
install_bottle_for?(dependent, build)
end
diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb
index 49108ca75..bd8cf20c8 100644
--- a/Library/Homebrew/requirement.rb
+++ b/Library/Homebrew/requirement.rb
@@ -125,6 +125,10 @@ class Requirement
@formula || self.class.default_formula
end
+ def satisfied_by_formula?
+ !@formula.nil?
+ end
+
def to_dependency
if formula =~ HOMEBREW_TAP_FORMULA_REGEX
TapDependency.new(formula, tags, method(:modify_build_environment), name)
diff --git a/Library/Homebrew/test/formula_installer_spec.rb b/Library/Homebrew/test/formula_installer_spec.rb
index 600b4560f..f5218db73 100644
--- a/Library/Homebrew/test/formula_installer_spec.rb
+++ b/Library/Homebrew/test/formula_installer_spec.rb
@@ -134,4 +134,43 @@ describe FormulaInstaller do
fi.check_install_sanity
}.to raise_error(CannotInstallFormulaError)
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