aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlyssa Ross2016-10-25 23:53:10 +0100
committerAlyssa Ross2016-10-25 23:53:10 +0100
commit3702e561d6e5a5d63a63da1da62bbcfc73545f96 (patch)
tree7301480911c871160161790c97fbd8b042d5575a
parent5a3d6c4c8f8254c8234157c16dbb80c23ffd49b1 (diff)
downloadbrew-3702e561d6e5a5d63a63da1da62bbcfc73545f96.tar.bz2
uninstall: test should_check_for_dependents?
-rw-r--r--Library/Homebrew/cmd/uninstall.rb10
-rw-r--r--Library/Homebrew/test/test_uninstall.rb22
2 files changed, 30 insertions, 2 deletions
diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb
index a05adece6..504ee9983 100644
--- a/Library/Homebrew/cmd/uninstall.rb
+++ b/Library/Homebrew/cmd/uninstall.rb
@@ -24,8 +24,7 @@ module Homebrew
ARGV.kegs.group_by(&:rack)
end
- # --ignore-dependencies, to be consistent with install
- if !ARGV.include?("--ignore-dependencies") && !ARGV.homebrew_developer?
+ if should_check_for_dependents?
all_kegs = kegs_by_rack.values.flatten(1)
return if check_for_dependents all_kegs
end
@@ -75,6 +74,13 @@ module Homebrew
end
end
+ def should_check_for_dependents?
+ # --ignore-dependencies, to be consistent with install
+ return false if ARGV.include?("--ignore-dependencies")
+ return false if ARGV.homebrew_developer?
+ true
+ end
+
def check_for_dependents(kegs)
return false unless result = Keg.find_some_installed_dependents(kegs)
diff --git a/Library/Homebrew/test/test_uninstall.rb b/Library/Homebrew/test/test_uninstall.rb
index a41e5e9d1..9999b2bb2 100644
--- a/Library/Homebrew/test/test_uninstall.rb
+++ b/Library/Homebrew/test/test_uninstall.rb
@@ -1,4 +1,26 @@
require "helper/integration_command_test_case"
+require "cmd/uninstall"
+
+class UninstallTests < Homebrew::TestCase
+ def test_check_for_testball_f2s_when_developer
+ refute_predicate Homebrew, :should_check_for_dependents?
+ end
+
+ def test_check_for_dependents_when_not_developer
+ run_as_not_developer do
+ assert_predicate Homebrew, :should_check_for_dependents?
+ end
+ end
+
+ def test_check_for_dependents_when_ignore_dependencies
+ ARGV << "--ignore-dependencies"
+ run_as_not_developer do
+ refute_predicate Homebrew, :should_check_for_dependents?
+ end
+ ensure
+ ARGV.delete("--ignore-dependencies")
+ end
+end
class IntegrationCommandTestUninstall < IntegrationCommandTestCase
def setup