From 4ef15427bacc84622561bde6b8474a1df996eb52 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Mon, 19 Oct 2015 20:06:15 +0800 Subject: [PATCH] add test for bottle disable Closes Homebrew/homebrew#43935. Signed-off-by: Xu Cheng --- Library/Homebrew/test/test_bottle_hooks.rb | 1 + Library/Homebrew/test/test_formula_installer.rb | 16 ++++++++++++++++ Library/Homebrew/test/test_formula_support.rb | 14 ++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/Library/Homebrew/test/test_bottle_hooks.rb b/Library/Homebrew/test/test_bottle_hooks.rb index ff9d95c9cd..1f889da178 100644 --- a/Library/Homebrew/test/test_bottle_hooks.rb +++ b/Library/Homebrew/test/test_bottle_hooks.rb @@ -6,6 +6,7 @@ class BottleHookTests < Homebrew::TestCase class FormulaDouble def bottle; end def local_bottle_path; end + def bottle_disabled?; false end def some_random_method true diff --git a/Library/Homebrew/test/test_formula_installer.rb b/Library/Homebrew/test/test_formula_installer.rb index 1bf3e43ba4..5c545692de 100644 --- a/Library/Homebrew/test/test_formula_installer.rb +++ b/Library/Homebrew/test/test_formula_installer.rb @@ -51,4 +51,20 @@ class InstallTests < Homebrew::TestCase assert_equal 3, bin.children.length end end + + 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 end diff --git a/Library/Homebrew/test/test_formula_support.rb b/Library/Homebrew/test/test_formula_support.rb index 08d10292f2..25514a032e 100644 --- a/Library/Homebrew/test/test_formula_support.rb +++ b/Library/Homebrew/test/test_formula_support.rb @@ -11,3 +11,17 @@ class KegOnlyReasonTests < Homebrew::TestCase assert_match(/^OS X already provides/, r.to_s) end end + +class BottleDisableReasonTests < Homebrew::TestCase + def test_bottle_unneeded + bottle_disable_reason = BottleDisableReason.new :unneeded, nil + assert_predicate bottle_disable_reason, :unneeded? + assert_equal "This formula doesn't require compiling.", bottle_disable_reason.to_s + end + + def test_bottle_disabled + bottle_disable_reason = BottleDisableReason.new :disable, "reason" + refute_predicate bottle_disable_reason, :unneeded? + assert_equal "reason", bottle_disable_reason.to_s + end +end