diff --git a/Library/Homebrew/test/bottles/testball_bottle-0.1.mavericks.bottle.tar.gz b/Library/Homebrew/test/bottles/testball_bottle-0.1.mavericks.bottle.tar.gz new file mode 120000 index 0000000000..3e989830ba --- /dev/null +++ b/Library/Homebrew/test/bottles/testball_bottle-0.1.mavericks.bottle.tar.gz @@ -0,0 +1 @@ +testball_bottle-0.1.yosemite.bottle.tar.gz \ No newline at end of file diff --git a/Library/Homebrew/test/bottles/testball_bottle-0.1.mountain_lion.bottle.tar.gz b/Library/Homebrew/test/bottles/testball_bottle-0.1.mountain_lion.bottle.tar.gz new file mode 120000 index 0000000000..3e989830ba --- /dev/null +++ b/Library/Homebrew/test/bottles/testball_bottle-0.1.mountain_lion.bottle.tar.gz @@ -0,0 +1 @@ +testball_bottle-0.1.yosemite.bottle.tar.gz \ No newline at end of file diff --git a/Library/Homebrew/test/bottles/testball_bottle-0.1.yosemite.bottle.tar.gz b/Library/Homebrew/test/bottles/testball_bottle-0.1.yosemite.bottle.tar.gz new file mode 100644 index 0000000000..d88838a94d Binary files /dev/null and b/Library/Homebrew/test/bottles/testball_bottle-0.1.yosemite.bottle.tar.gz differ diff --git a/Library/Homebrew/test/test_formula_installer_bottle.rb b/Library/Homebrew/test/test_formula_installer_bottle.rb new file mode 100644 index 0000000000..4d2d1676f8 --- /dev/null +++ b/Library/Homebrew/test/test_formula_installer_bottle.rb @@ -0,0 +1,78 @@ +require "testing_env" +require "formula" +require "compat/formula_specialties" +require "formula_installer" +require "keg" +require "testball_bottle" +require "testball" + +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 + yield formula + ensure + keg.unlink + keg.uninstall + formula.clear_cache + Dir["#{HOMEBREW_CACHE}/testball_bottle*"].each { |f| File.delete(f) } + # there will be log files when sandbox is enable. + formula.logs.rmtree if formula.logs.directory? + 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 diff --git a/Library/Homebrew/test/testball_bottle.rb b/Library/Homebrew/test/testball_bottle.rb new file mode 100644 index 0000000000..27ffd972aa --- /dev/null +++ b/Library/Homebrew/test/testball_bottle.rb @@ -0,0 +1,17 @@ +class TestballBottle < Formula + def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable) + self.class.instance_eval do + stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz" + stable.sha256 "1dfb13ce0f6143fe675b525fc9e168adb2215c5d5965c9f57306bb993170914f" + stable.bottle do + cellar :any_skip_relocation + root_url "file://#{File.expand_path("..", __FILE__)}/bottles" + sha256 "9abc8ce779067e26556002c4ca6b9427b9874d25f0cafa7028e05b5c5c410cb4" => :yosemite + sha256 "9abc8ce779067e26556002c4ca6b9427b9874d25f0cafa7028e05b5c5c410cb4" => :mavericks + sha256 "9abc8ce779067e26556002c4ca6b9427b9874d25f0cafa7028e05b5c5c410cb4" => :mountain_lion + end + cxxstdlib_check :skip + end + super + end +end