Don't create Caskroom.path for tests.

This commit is contained in:
Markus Reiter 2018-06-09 11:32:49 +02:00
parent 767ebe6ab6
commit 1d27c5f79a
3 changed files with 6 additions and 6 deletions

View File

@ -9,10 +9,12 @@ module Hbc
def ensure_caskroom_exists def ensure_caskroom_exists
return if path.exist? return if path.exist?
ohai "Creating Caskroom at #{path}" if $stdout.tty?
sudo = !path.parent.writable? sudo = !path.parent.writable?
ohai "We'll set permissions properly so we won't need sudo in the future" if $stdout.tty? && sudo if sudo && !ENV.key?("SUDO_ASKPASS") && $stdout.tty?
ohai "Creating Caskroom at #{path}"
ohai "We'll set permissions properly so we won't need sudo in the future."
end
SystemCommand.run("/bin/mkdir", args: ["-p", path], sudo: sudo) SystemCommand.run("/bin/mkdir", args: ["-p", path], sudo: sudo)
SystemCommand.run("/bin/chmod", args: ["g+rwx", path], sudo: sudo) SystemCommand.run("/bin/chmod", args: ["g+rwx", path], sudo: sudo)

View File

@ -62,9 +62,7 @@ module Hbc
path = Pathname.new(user_tilde(Caskroom.path.to_s)) path = Pathname.new(user_tilde(Caskroom.path.to_s))
if !path.exist? if path.exist? && !path.writable?
add_error "The staging path #{path} does not exist."
elsif !path.writable?
add_error "The staging path #{path} is not writable by the current user." add_error "The staging path #{path} is not writable by the current user."
end end

View File

@ -23,7 +23,7 @@ RSpec.shared_context "Homebrew-Cask" do
begin begin
HOMEBREW_CASK_DIRS.values.each(&:mkpath) HOMEBREW_CASK_DIRS.values.each(&:mkpath)
[Hbc::Config.global.binarydir, Hbc::Caskroom.path].each(&:mkpath) [Hbc::Config.global.binarydir].each(&:mkpath)
Tap.default_cask_tap.tap do |tap| Tap.default_cask_tap.tap do |tap|
FileUtils.mkdir_p tap.path.dirname FileUtils.mkdir_p tap.path.dirname