2010-02-18 11:40:59 -08:00
|
|
|
require 'testing_env'
|
|
|
|
require 'formula'
|
2010-03-02 22:54:12 -08:00
|
|
|
require 'test/testball'
|
2010-02-18 11:40:59 -08:00
|
|
|
require 'keg'
|
|
|
|
|
|
|
|
|
2012-06-20 00:51:01 -05:00
|
|
|
class TestScriptFileFormula < ScriptFileFormula
|
2014-04-06 15:52:04 -05:00
|
|
|
url "file:///#{__FILE__}"
|
2010-02-18 11:40:59 -08:00
|
|
|
version "1"
|
2012-06-20 00:51:01 -05:00
|
|
|
|
2014-04-06 15:52:04 -05:00
|
|
|
def initialize(name="test_script_formula", path=nil)
|
2010-02-18 11:40:59 -08:00
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2010-04-03 08:44:41 -07:00
|
|
|
class ConfigureTests < Test::Unit::TestCase
|
2013-09-14 11:51:36 -05:00
|
|
|
def teardown
|
|
|
|
HOMEBREW_CACHE.rmtree
|
|
|
|
end
|
|
|
|
|
2010-04-03 08:44:41 -07:00
|
|
|
def test_detect_failed_configure
|
2012-04-16 23:40:40 -05:00
|
|
|
f = ConfigureFails.new
|
2013-04-07 18:40:40 -05:00
|
|
|
shutup { f.brew { f.install } }
|
|
|
|
rescue BuildError => e
|
|
|
|
assert e.was_running_configure?
|
2010-04-03 08:44:41 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2010-02-18 11:40:59 -08:00
|
|
|
class InstallTests < Test::Unit::TestCase
|
2013-09-14 11:51:36 -05:00
|
|
|
def teardown
|
|
|
|
HOMEBREW_CACHE.rmtree
|
|
|
|
end
|
|
|
|
|
2010-02-18 11:40:59 -08:00
|
|
|
def temporary_install f
|
|
|
|
# Brew and install the given formula
|
2013-04-01 12:15:29 -05:00
|
|
|
shutup do
|
2010-02-18 11:40:59 -08:00
|
|
|
f.brew { f.install }
|
|
|
|
end
|
|
|
|
|
|
|
|
# Allow the test to do some processing
|
|
|
|
yield
|
2012-06-20 00:51:01 -05:00
|
|
|
|
2010-02-18 11:40:59 -08:00
|
|
|
# Remove the brewed formula and double check
|
|
|
|
# that it did get removed. This lets multiple
|
|
|
|
# tests use the same formula name without
|
|
|
|
# stepping on each other.
|
|
|
|
keg=Keg.new f.prefix
|
2012-04-16 16:43:42 -05:00
|
|
|
keg.unlink
|
2010-02-18 11:40:59 -08:00
|
|
|
keg.uninstall
|
|
|
|
assert !keg.exist?
|
|
|
|
assert !f.installed?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_a_basic_install
|
|
|
|
f=TestBall.new
|
2012-06-20 00:51:01 -05:00
|
|
|
|
2010-02-18 11:40:59 -08:00
|
|
|
assert !f.installed?
|
2012-06-20 00:51:01 -05:00
|
|
|
|
2010-02-18 11:40:59 -08:00
|
|
|
temporary_install f do
|
2012-06-20 00:51:01 -05:00
|
|
|
|
2010-02-18 11:40:59 -08:00
|
|
|
# Test that things made it into the Keg
|
|
|
|
assert f.bin.directory?
|
|
|
|
assert_equal 3, f.bin.children.length
|
|
|
|
libexec=f.prefix+'libexec'
|
|
|
|
assert libexec.directory?
|
|
|
|
assert_equal 1, libexec.children.length
|
|
|
|
assert !(f.prefix+'main.c').exist?
|
|
|
|
assert f.installed?
|
2012-06-20 00:51:01 -05:00
|
|
|
|
2010-02-18 11:40:59 -08:00
|
|
|
# Test that things make it into the Cellar
|
|
|
|
keg=Keg.new f.prefix
|
|
|
|
keg.link
|
2012-08-29 15:37:58 -05:00
|
|
|
assert_equal 3, HOMEBREW_PREFIX.children.length
|
2013-03-28 17:37:29 -05:00
|
|
|
assert((HOMEBREW_PREFIX+'bin').directory?)
|
2010-02-18 11:40:59 -08:00
|
|
|
assert_equal 3, (HOMEBREW_PREFIX+'bin').children.length
|
|
|
|
end
|
|
|
|
end
|
2012-06-20 00:51:01 -05:00
|
|
|
|
2010-02-18 11:40:59 -08:00
|
|
|
def test_script_install
|
|
|
|
f=TestScriptFileFormula.new
|
2012-06-20 00:51:01 -05:00
|
|
|
|
2010-02-18 11:40:59 -08:00
|
|
|
temporary_install f do
|
2013-04-01 12:15:29 -05:00
|
|
|
shutup do
|
2010-02-18 11:40:59 -08:00
|
|
|
f.brew { f.install }
|
|
|
|
end
|
2012-06-20 00:51:01 -05:00
|
|
|
|
2010-02-18 11:40:59 -08:00
|
|
|
assert_equal 1, f.bin.children.length
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|