brew/Library/Homebrew/test/test_formula_installer_bottle.rb
Daniel Trebbien af10515f81 Skip pouring from a bottle if --cc is passed
A formula should be built from source by default if the --cc option is
passed to specify a particular compiler.

Added a test to test_formula_installer: test_not_poured_from_bottle_when_compiler_specified

Modified test_formula_installer to assert that the formula was not poured
from a bottle. Similarly modified test_formula_installer_bottle to assert
that the formula *was* installed from a bottle.

Added an install method to the TestballBottle formula (the same as the
Testball formula's install method) so that the TestballBottle formula can
be "built from source".

Fixes Homebrew/homebrew#46046 - Build from source should be the default behavior if --cc
option is passed

Closes Homebrew/homebrew#46162.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-11-25 16:49:58 +00:00

80 lines
1.9 KiB
Ruby

require "testing_env"
require "formula"
require "compat/formula_specialties"
require "formula_installer"
require "keg"
require "tab"
require "testball"
require "testball_bottle"
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
assert_predicate Tab.for_keg(keg), :poured_from_bottle
yield formula
ensure
keg.unlink
keg.uninstall
formula.clear_cache
formula.bottle.clear_cache
end
refute_predicate keg, :exist?
refute_predicate formula, :installed?
end
def test_a_basic_bottle_install
MacOS.stubs(:has_apple_developer_tools?).returns(false)
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
MacOS.stubs(:has_apple_developer_tools?).returns(false)
# 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
installer.install
end
refute_predicate formula, :installed?
end
end