2015-08-14 14:21:39 -04:00
|
|
|
require "testing_env"
|
|
|
|
require "formula"
|
|
|
|
require "formula_installer"
|
|
|
|
require "keg"
|
2015-11-19 07:54:27 -05:00
|
|
|
require "tab"
|
2015-08-14 14:21:39 -04:00
|
|
|
require "testball"
|
2015-11-19 07:54:27 -05:00
|
|
|
require "testball_bottle"
|
2015-08-14 14:21:39 -04:00
|
|
|
|
|
|
|
class InstallBottleTests < Homebrew::TestCase
|
|
|
|
def temporary_bottle_install(formula)
|
|
|
|
refute_predicate formula, :installed?
|
|
|
|
assert_predicate formula, :bottled?
|
|
|
|
assert_predicate formula, :pour_bottle?
|
|
|
|
|
|
|
|
installer = FormulaInstaller.new(formula)
|
|
|
|
|
|
|
|
shutup { installer.install }
|
|
|
|
|
|
|
|
keg = Keg.new(formula.prefix)
|
|
|
|
|
|
|
|
assert_predicate formula, :installed?
|
|
|
|
|
|
|
|
begin
|
2015-11-19 07:54:27 -05:00
|
|
|
assert_predicate Tab.for_keg(keg), :poured_from_bottle
|
|
|
|
|
2015-08-14 14:21:39 -04:00
|
|
|
yield formula
|
|
|
|
ensure
|
|
|
|
keg.unlink
|
|
|
|
keg.uninstall
|
|
|
|
formula.clear_cache
|
2015-09-06 20:47:40 +08:00
|
|
|
formula.bottle.clear_cache
|
2015-08-14 14:21:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
refute_predicate keg, :exist?
|
|
|
|
refute_predicate formula, :installed?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_a_basic_bottle_install
|
2016-07-06 11:07:24 +01:00
|
|
|
DevelopmentTools.stubs(:installed?).returns(false)
|
2015-08-14 14:21:39 -04:00
|
|
|
|
|
|
|
temporary_bottle_install(TestballBottle.new) do |f|
|
|
|
|
# Copied directly from test_formula_installer.rb as we expect
|
|
|
|
# the same behavior
|
|
|
|
|
|
|
|
# Test that things made it into the Keg
|
|
|
|
assert_predicate f.bin, :directory?
|
|
|
|
|
|
|
|
assert_predicate f.libexec, :directory?
|
|
|
|
|
|
|
|
refute_predicate f.prefix+"main.c", :exist?
|
|
|
|
|
|
|
|
# Test that things make it into the Cellar
|
|
|
|
keg = Keg.new f.prefix
|
|
|
|
keg.link
|
|
|
|
|
|
|
|
bin = HOMEBREW_PREFIX+"bin"
|
|
|
|
assert_predicate bin, :directory?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_build_tools_error
|
2016-07-06 11:07:24 +01:00
|
|
|
DevelopmentTools.stubs(:installed?).returns(false)
|
2015-08-14 14:21:39 -04:00
|
|
|
|
|
|
|
# Testball doesn't have a bottle block, so use it to test this behavior
|
|
|
|
formula = Testball.new
|
|
|
|
|
|
|
|
refute_predicate formula, :installed?
|
|
|
|
refute_predicate formula, :bottled?
|
|
|
|
|
|
|
|
installer = FormulaInstaller.new(formula)
|
|
|
|
|
|
|
|
assert_raises(BuildToolsError) do
|
2015-08-22 13:15:33 +08:00
|
|
|
installer.install
|
2015-08-14 14:21:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
refute_predicate formula, :installed?
|
|
|
|
end
|
|
|
|
end
|