aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorL. E. Segovia2017-11-10 10:05:18 -0300
committerL. E. Segovia2017-11-10 11:33:44 -0300
commit72e673afaeec817c38465dcb9c652ef7556d0b52 (patch)
tree19844f81e04570a4a88d0662dde39730e90874a2
parent522a229dbb0e558b8898df60095527e081500655 (diff)
downloadbrew-72e673afaeec817c38465dcb9c652ef7556d0b52.tar.bz2
Fix reinstall/uninstall tests
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/moved.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb12
-rw-r--r--Library/Homebrew/test/cask/cli/reinstall_spec.rb3
-rw-r--r--Library/Homebrew/test/cask/cli/uninstall_spec.rb3
4 files changed, 13 insertions, 9 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb
index a2f890e4c..dacbe20b7 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb
@@ -25,7 +25,7 @@ module Hbc
private
- def move(source, target, force: false, command: nil, **options)
+ def move(source, target, skip: false, force: false, command: nil, **options)
if Utils.path_occupied?(target)
message = "It seems there is already #{self.class.english_article} #{self.class.english_name} at '#{target}'"
raise CaskError, "#{message}." unless force
@@ -34,6 +34,8 @@ module Hbc
end
unless source.exist?
+ return if skip
+
raise CaskError, "It seems the #{self.class.english_name} source '#{source}' is not there."
end
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 88b77c62c..03f2c6570 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -368,7 +368,7 @@ module Hbc
def uninstall
oh1 "Uninstalling Cask #{@cask}"
disable_accessibility_access
- uninstall_artifacts
+ uninstall_artifacts(clear: true)
purge_versioned_files
purge_caskroom_path if force?
end
@@ -390,10 +390,10 @@ module Hbc
def finalize_upgrade
return unless upgrade?
- purge_versioned_files(upgrade: true)
+ purge_versioned_files
end
- def uninstall_artifacts
+ def uninstall_artifacts(clear: false)
odebug "Un-installing artifacts"
artifacts = @cask.artifacts
@@ -402,7 +402,7 @@ module Hbc
artifacts.each do |artifact|
next unless artifact.respond_to?(:uninstall_phase)
odebug "Un-installing artifact of class #{artifact.class}"
- artifact.uninstall_phase(command: @command, verbose: verbose?, force: force?)
+ artifact.uninstall_phase(command: @command, verbose: verbose?, skip: clear, force: force?)
end
end
@@ -425,8 +425,8 @@ module Hbc
Utils.gain_permissions_remove(path, command: @command)
end
- def purge_versioned_files(upgrade: false)
- odebug "Purging files for version #{@cask.version} of Cask #{@cask}" unless upgrade?
+ def purge_versioned_files
+ ohai "Purging files for version #{@cask.version} of Cask #{@cask}"
# versioned staged distribution
gain_permissions_remove(@cask.staged_path) if !@cask.staged_path.nil? && @cask.staged_path.exist?
diff --git a/Library/Homebrew/test/cask/cli/reinstall_spec.rb b/Library/Homebrew/test/cask/cli/reinstall_spec.rb
index 5e551e5b5..1df814715 100644
--- a/Library/Homebrew/test/cask/cli/reinstall_spec.rb
+++ b/Library/Homebrew/test/cask/cli/reinstall_spec.rb
@@ -13,7 +13,8 @@ describe Hbc::CLI::Reinstall, :cask do
Already downloaded: .*local-caffeine--1.2.3.zip
==> Verifying checksum for Cask local-caffeine
==> Uninstalling Cask local-caffeine
- ==> Removing App '.*Caffeine.app'.
+ ==> Moving App 'Caffeine.app' to '.*Caffeine.app'.
+ ==> Purging files for version 1.2.3 of Cask local-caffeine
==> Installing Cask local-caffeine
==> Moving App 'Caffeine.app' to '.*Caffeine.app'.
.*local-caffeine was successfully installed!
diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb
index 1ab8f7e4d..578c0d43a 100644
--- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb
+++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb
@@ -12,7 +12,8 @@ describe Hbc::CLI::Uninstall, :cask do
output = Regexp.new <<~EOS
==> Uninstalling Cask local-caffeine
- ==> Removing App '.*Caffeine.app'.
+ ==> Moving App 'Caffeine.app' to '.*Caffeine.app'.
+ ==> Purging files for version 1.2.3 of Cask local-caffeine
EOS
expect {