2015-04-28 22:37:27 -04:00
|
|
|
require "testing_env"
|
|
|
|
require "formula"
|
|
|
|
require "formula_installer"
|
|
|
|
require "keg"
|
2015-11-19 07:54:27 -05:00
|
|
|
require "tab"
|
2016-10-24 22:53:25 +02:00
|
|
|
require "test/support/fixtures/testball"
|
|
|
|
require "test/support/fixtures/testball_bottle"
|
2015-04-28 22:37:27 -04:00
|
|
|
|
|
|
|
class InstallTests < Homebrew::TestCase
|
|
|
|
def temporary_install(formula)
|
|
|
|
refute_predicate formula, :installed?
|
|
|
|
|
|
|
|
installer = FormulaInstaller.new(formula)
|
|
|
|
|
|
|
|
shutup { installer.install }
|
|
|
|
|
|
|
|
keg = Keg.new(formula.prefix)
|
|
|
|
|
|
|
|
assert_predicate formula, :installed?
|
|
|
|
|
|
|
|
begin
|
2015-11-27 16:40:16 +00:00
|
|
|
Tab.clear_cache
|
2015-11-19 07:54:27 -05:00
|
|
|
refute_predicate Tab.for_keg(keg), :poured_from_bottle
|
|
|
|
|
2015-04-28 22:37:27 -04:00
|
|
|
yield formula
|
|
|
|
ensure
|
2015-11-27 16:40:16 +00:00
|
|
|
Tab.clear_cache
|
2015-04-28 22:37:27 -04:00
|
|
|
keg.unlink
|
|
|
|
keg.uninstall
|
|
|
|
formula.clear_cache
|
2015-07-21 17:23:04 +08:00
|
|
|
# there will be log files when sandbox is enable.
|
|
|
|
formula.logs.rmtree if formula.logs.directory?
|
2015-04-28 22:37:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
refute_predicate keg, :exist?
|
|
|
|
refute_predicate formula, :installed?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_a_basic_install
|
2016-10-03 09:42:53 +01:00
|
|
|
ARGV << "--with-invalid_flag" # added to ensure it doesn't fail install
|
2015-04-28 22:37:27 -04:00
|
|
|
temporary_install(Testball.new) do |f|
|
|
|
|
# Test that things made it into the Keg
|
2016-01-17 17:17:42 -08:00
|
|
|
assert_predicate f.prefix+"readme", :exist?
|
|
|
|
|
2015-04-28 22:37:27 -04:00
|
|
|
assert_predicate f.bin, :directory?
|
|
|
|
assert_equal 3, f.bin.children.length
|
|
|
|
|
|
|
|
assert_predicate f.libexec, :directory?
|
|
|
|
assert_equal 1, f.libexec.children.length
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
refute_predicate f.prefix+"main.c", :exist?
|
2015-04-28 22:37:27 -04:00
|
|
|
|
2016-01-17 17:17:42 -08:00
|
|
|
refute_predicate f.prefix+"license", :exist?
|
|
|
|
|
2015-04-28 22:37:27 -04:00
|
|
|
# Test that things make it into the Cellar
|
|
|
|
keg = Keg.new f.prefix
|
|
|
|
keg.link
|
|
|
|
|
|
|
|
bin = HOMEBREW_PREFIX+"bin"
|
|
|
|
assert_predicate bin, :directory?
|
|
|
|
assert_equal 3, bin.children.length
|
2016-09-20 14:42:29 -07:00
|
|
|
assert_predicate f.prefix/".brew/testball.rb", :readable?
|
2015-04-28 22:37:27 -04:00
|
|
|
end
|
|
|
|
end
|
2015-10-19 20:06:15 +08:00
|
|
|
|
|
|
|
def test_bottle_unneeded_formula_install
|
2016-07-06 11:07:24 +01:00
|
|
|
DevelopmentTools.stubs(:installed?).returns(false)
|
2015-10-19 20:06:15 +08:00
|
|
|
|
|
|
|
formula = Testball.new
|
|
|
|
formula.stubs(:bottle_unneeded?).returns(true)
|
|
|
|
formula.stubs(:bottle_disabled?).returns(true)
|
|
|
|
|
|
|
|
refute_predicate formula, :bottled?
|
|
|
|
assert_predicate formula, :bottle_unneeded?
|
|
|
|
assert_predicate formula, :bottle_disabled?
|
|
|
|
|
|
|
|
temporary_install(formula) do |f|
|
|
|
|
assert_predicate f, :installed?
|
|
|
|
end
|
|
|
|
end
|
2015-11-19 07:54:27 -05:00
|
|
|
|
|
|
|
def test_not_poured_from_bottle_when_compiler_specified
|
|
|
|
assert_nil ARGV.cc
|
|
|
|
|
2016-05-22 09:40:08 +01:00
|
|
|
cc_arg = "--cc=clang"
|
2015-11-19 07:54:27 -05:00
|
|
|
ARGV << cc_arg
|
2017-01-21 15:08:20 +00:00
|
|
|
|
|
|
|
temporary_install(TestballBottle.new) do |f|
|
|
|
|
tab = Tab.for_formula(f)
|
|
|
|
assert_equal "clang", tab.compiler
|
2015-11-19 07:54:27 -05:00
|
|
|
end
|
|
|
|
end
|
2015-04-28 22:37:27 -04:00
|
|
|
end
|
2016-09-05 23:33:37 +03:00
|
|
|
|
|
|
|
class FormulaInstallerTests < Homebrew::TestCase
|
|
|
|
def test_check_install_sanity_pinned_dep
|
|
|
|
dep_name = "dependency"
|
|
|
|
dep_path = CoreTap.new.formula_dir/"#{dep_name}.rb"
|
|
|
|
dep_path.write <<-EOS.undent
|
|
|
|
class #{Formulary.class_s(dep_name)} < Formula
|
|
|
|
url "foo"
|
|
|
|
version "0.2"
|
|
|
|
end
|
|
|
|
EOS
|
|
|
|
|
|
|
|
Formulary::FORMULAE.delete(dep_path)
|
|
|
|
dependency = Formulary.factory(dep_name)
|
|
|
|
|
|
|
|
dependent = formula do
|
|
|
|
url "foo"
|
|
|
|
version "0.5"
|
2016-09-11 17:43:09 +01:00
|
|
|
depends_on dependency.name.to_s
|
2016-09-05 23:33:37 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
dependency.prefix("0.1").join("bin/a").mkpath
|
2016-09-15 18:28:42 +01:00
|
|
|
HOMEBREW_PINNED_KEGS.mkpath
|
|
|
|
FileUtils.ln_s dependency.prefix("0.1"), HOMEBREW_PINNED_KEGS/dep_name
|
2016-09-05 23:33:37 +03:00
|
|
|
|
|
|
|
dependency_keg = Keg.new(dependency.prefix("0.1"))
|
|
|
|
dependency_keg.link
|
|
|
|
|
|
|
|
assert_predicate dependency_keg, :linked?
|
|
|
|
assert_predicate dependency, :pinned?
|
|
|
|
|
|
|
|
fi = FormulaInstaller.new(dependent)
|
|
|
|
assert_raises(CannotInstallFormulaError) { fi.check_install_sanity }
|
|
|
|
ensure
|
|
|
|
dependency_keg.unlink
|
|
|
|
Formulary::FORMULAE.delete(dep_path)
|
|
|
|
end
|
|
|
|
end
|