test/formula_installer_spec: add tests for cyclic deps
This commit is contained in:
parent
73d372e951
commit
fa8b80747a
@ -96,40 +96,97 @@ describe FormulaInstaller do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "check installation sanity pinned dependency" do
|
describe "#check_install_sanity" do
|
||||||
dep_name = "dependency"
|
it "raises on direct cyclic dependency" do
|
||||||
dep_path = CoreTap.new.formula_dir/"#{dep_name}.rb"
|
ENV["HOMEBREW_DEVELOPER"] = "1"
|
||||||
dep_path.write <<~RUBY
|
|
||||||
class #{Formulary.class_s(dep_name)} < Formula
|
|
||||||
url "foo"
|
|
||||||
version "0.2"
|
|
||||||
end
|
|
||||||
RUBY
|
|
||||||
|
|
||||||
Formulary.cache.delete(dep_path)
|
dep_name = "homebrew-test-cyclic"
|
||||||
dependency = Formulary.factory(dep_name)
|
dep_path = CoreTap.new.formula_dir/"#{dep_name}.rb"
|
||||||
|
dep_path.write <<~RUBY
|
||||||
|
class #{Formulary.class_s(dep_name)} < Formula
|
||||||
|
url "foo"
|
||||||
|
version "0.1"
|
||||||
|
depends_on "#{dep_name}"
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
Formulary.cache.delete(dep_path)
|
||||||
|
f = Formulary.factory(dep_name)
|
||||||
|
|
||||||
dependent = formula do
|
fi = described_class.new(f)
|
||||||
url "foo"
|
|
||||||
version "0.5"
|
expect {
|
||||||
depends_on dependency.name.to_s
|
fi.check_install_sanity
|
||||||
|
}.to raise_error(CannotInstallFormulaError)
|
||||||
end
|
end
|
||||||
|
|
||||||
(dependency.prefix("0.1")/"bin"/"a").mkpath
|
it "raises on indirect cyclic dependency" do
|
||||||
HOMEBREW_PINNED_KEGS.mkpath
|
ENV["HOMEBREW_DEVELOPER"] = "1"
|
||||||
FileUtils.ln_s dependency.prefix("0.1"), HOMEBREW_PINNED_KEGS/dep_name
|
|
||||||
|
|
||||||
dependency_keg = Keg.new(dependency.prefix("0.1"))
|
formula1_name = "homebrew-test-formula1"
|
||||||
dependency_keg.link
|
formula2_name = "homebrew-test-formula2"
|
||||||
|
formula1_path = CoreTap.new.formula_dir/"#{formula1_name}.rb"
|
||||||
|
formula1_path.write <<~RUBY
|
||||||
|
class #{Formulary.class_s(formula1_name)} < Formula
|
||||||
|
url "foo"
|
||||||
|
version "0.1"
|
||||||
|
depends_on "#{formula2_name}"
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
Formulary.cache.delete(formula1_path)
|
||||||
|
formula1 = Formulary.factory(formula1_name)
|
||||||
|
|
||||||
expect(dependency_keg).to be_linked
|
formula2_path = CoreTap.new.formula_dir/"#{formula2_name}.rb"
|
||||||
expect(dependency).to be_pinned
|
formula2_path.write <<~RUBY
|
||||||
|
class #{Formulary.class_s(formula2_name)} < Formula
|
||||||
|
url "foo"
|
||||||
|
version "0.1"
|
||||||
|
depends_on "#{formula1_name}"
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
Formulary.cache.delete(formula2_path)
|
||||||
|
|
||||||
fi = described_class.new(dependent)
|
fi = described_class.new(formula1)
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
fi.check_install_sanity
|
fi.check_install_sanity
|
||||||
}.to raise_error(CannotInstallFormulaError)
|
}.to raise_error(CannotInstallFormulaError)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "raises on pinned dependency" do
|
||||||
|
dep_name = "homebrew-test-dependency"
|
||||||
|
dep_path = CoreTap.new.formula_dir/"#{dep_name}.rb"
|
||||||
|
dep_path.write <<~RUBY
|
||||||
|
class #{Formulary.class_s(dep_name)} < Formula
|
||||||
|
url "foo"
|
||||||
|
version "0.2"
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
Formulary.cache.delete(dep_path)
|
||||||
|
dependency = Formulary.factory(dep_name)
|
||||||
|
|
||||||
|
dependent = formula do
|
||||||
|
url "foo"
|
||||||
|
version "0.5"
|
||||||
|
depends_on dependency.name.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
(dependency.prefix("0.1")/"bin"/"a").mkpath
|
||||||
|
HOMEBREW_PINNED_KEGS.mkpath
|
||||||
|
FileUtils.ln_s dependency.prefix("0.1"), HOMEBREW_PINNED_KEGS/dep_name
|
||||||
|
|
||||||
|
dependency_keg = Keg.new(dependency.prefix("0.1"))
|
||||||
|
dependency_keg.link
|
||||||
|
|
||||||
|
expect(dependency_keg).to be_linked
|
||||||
|
expect(dependency).to be_pinned
|
||||||
|
|
||||||
|
fi = described_class.new(dependent)
|
||||||
|
|
||||||
|
expect {
|
||||||
|
fi.check_install_sanity
|
||||||
|
}.to raise_error(CannotInstallFormulaError)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "install fails with BuildError when a system() call fails" do
|
specify "install fails with BuildError when a system() call fails" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user