2015-04-28 22:37:27 -04:00
|
|
|
require "testing_env"
|
|
|
|
require "formula"
|
|
|
|
require "compat/formula_specialties"
|
|
|
|
require "formula_installer"
|
|
|
|
require "keg"
|
2015-11-19 07:54:27 -05:00
|
|
|
require "tab"
|
2015-04-28 22:37:27 -04:00
|
|
|
require "testball"
|
2015-11-19 07:54:27 -05:00
|
|
|
require "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
|
|
|
|
temporary_install(Testball.new) do |f|
|
|
|
|
# Test that things made it into the Keg
|
|
|
|
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
|
|
|
|
|
|
|
# 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
|
|
|
|
end
|
|
|
|
end
|
2015-10-19 20:06:15 +08:00
|
|
|
|
|
|
|
def test_bottle_unneeded_formula_install
|
|
|
|
MacOS.stubs(:has_apple_developer_tools?).returns(false)
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
cc_arg = "--cc=llvm-gcc"
|
|
|
|
ARGV << cc_arg
|
|
|
|
begin
|
|
|
|
temporary_install(TestballBottle.new) do |f|
|
|
|
|
tab = Tab.for_formula(f)
|
|
|
|
assert_equal "llvm", tab.compiler
|
|
|
|
end
|
|
|
|
ensure
|
|
|
|
ARGV.delete_if { |x| x == cc_arg }
|
|
|
|
end
|
|
|
|
end
|
2015-04-28 22:37:27 -04:00
|
|
|
end
|