uninstall: test should_check_for_dependents?

This commit is contained in:
Alyssa Ross 2016-10-25 23:53:10 +01:00
parent 5a3d6c4c8f
commit 3702e561d6
2 changed files with 30 additions and 2 deletions

View File

@ -24,8 +24,7 @@ module Homebrew
ARGV.kegs.group_by(&:rack) ARGV.kegs.group_by(&:rack)
end end
# --ignore-dependencies, to be consistent with install if should_check_for_dependents?
if !ARGV.include?("--ignore-dependencies") && !ARGV.homebrew_developer?
all_kegs = kegs_by_rack.values.flatten(1) all_kegs = kegs_by_rack.values.flatten(1)
return if check_for_dependents all_kegs return if check_for_dependents all_kegs
end end
@ -75,6 +74,13 @@ module Homebrew
end end
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) def check_for_dependents(kegs)
return false unless result = Keg.find_some_installed_dependents(kegs) return false unless result = Keg.find_some_installed_dependents(kegs)

View File

@ -1,4 +1,26 @@
require "helper/integration_command_test_case" 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 class IntegrationCommandTestUninstall < IntegrationCommandTestCase
def setup def setup