Skip to content

Commit

Permalink
uninstall: fix dependent order bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alyssais committed Oct 25, 2016
1 parent 08c898f commit 888c44b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/uninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def uninstall

if !ARGV.force?
ARGV.kegs.each do |keg|
dependents = keg.installed_dependents
dependents = keg.installed_dependents - ARGV.kegs
if dependents.any?
dependents_output = dependents.map { |k| "#{k.name} #{k.version}" }.join(", ")
conjugation = dependents.count == 1 ? "is" : "are"
Expand Down
35 changes: 35 additions & 0 deletions Library/Homebrew/test/test_uninstall.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
require "helper/integration_command_test_case"

class IntegrationCommandTestUninstall < IntegrationCommandTestCase
def setup
super
@f1_path = setup_test_formula "testball_f1", <<-CONTENT
def install
FileUtils.touch prefix/touch("hello")
end
CONTENT
@f2_path = setup_test_formula "testball_f2", <<-CONTENT
depends_on "testball_f1"
def install
FileUtils.touch prefix/touch("hello")
end
CONTENT
end

def test_uninstall
cmd("install", testball)
assert_match "Uninstalling testball", cmd("uninstall", "--force", testball)
end

def test_uninstall_leaving_dependents
cmd("install", "testball_f2")
assert_match "Refusing to uninstall", cmd_fail("uninstall", "testball_f1")
assert_match "Uninstalling #{Formulary.factory(@f2_path).rack}",
cmd("uninstall", "testball_f2")
end

def test_uninstall_dependent_first
cmd("install", "testball_f2")
assert_match "Uninstalling #{Formulary.factory(@f1_path).rack}",
cmd("uninstall", "testball_f2", "testball_f1")
end

def test_uninstall_dependent_last
cmd("install", "testball_f2")
assert_match "Uninstalling #{Formulary.factory(@f2_path).rack}",
cmd("uninstall", "testball_f1", "testball_f2")
end
end

0 comments on commit 888c44b

Please sign in to comment.