Merge pull request #5660 from reitermarkus/save-cask-config
Save cask config for reinstall/uninstall/upgrade.
This commit is contained in:
commit
e8a7592176
@ -94,11 +94,14 @@ module Cask
|
|||||||
[executable, arguments]
|
[executable, arguments]
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :cask, :config
|
attr_reader :cask
|
||||||
|
|
||||||
def initialize(cask)
|
def initialize(cask)
|
||||||
@cask = cask
|
@cask = cask
|
||||||
@config = cask.config
|
end
|
||||||
|
|
||||||
|
def config
|
||||||
|
cask.config
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|||||||
@ -31,15 +31,21 @@ module Cask
|
|||||||
@tap
|
@tap
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(token, sourcefile_path: nil, tap: nil, config: Config.global, &block)
|
def initialize(token, sourcefile_path: nil, tap: nil, &block)
|
||||||
@token = token
|
@token = token
|
||||||
@sourcefile_path = sourcefile_path
|
@sourcefile_path = sourcefile_path
|
||||||
@tap = tap
|
@tap = tap
|
||||||
@config = config
|
@block = block
|
||||||
@dsl = DSL.new(self)
|
self.config = Config.for_cask(self)
|
||||||
return unless block_given?
|
end
|
||||||
|
|
||||||
@dsl.instance_eval(&block)
|
def config=(config)
|
||||||
|
@config = config
|
||||||
|
|
||||||
|
@dsl = DSL.new(self)
|
||||||
|
return unless @block
|
||||||
|
|
||||||
|
@dsl.instance_eval(&@block)
|
||||||
@dsl.language_eval
|
@dsl.language_eval
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -77,6 +83,14 @@ module Cask
|
|||||||
metadata_master_container_path.join(*installed_version, "Casks", "#{token}.rb")
|
metadata_master_container_path.join(*installed_version, "Casks", "#{token}.rb")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def config_path
|
||||||
|
metadata_master_container_path/"config.json"
|
||||||
|
end
|
||||||
|
|
||||||
|
def caskroom_path
|
||||||
|
@caskroom_path ||= Caskroom.path.join(token)
|
||||||
|
end
|
||||||
|
|
||||||
def outdated?(greedy = false)
|
def outdated?(greedy = false)
|
||||||
!outdated_versions(greedy).empty?
|
!outdated_versions(greedy).empty?
|
||||||
end
|
end
|
||||||
|
|||||||
@ -186,7 +186,10 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def process_options(*args)
|
def process_options(*args)
|
||||||
all_args = Shellwords.shellsplit(ENV["HOMEBREW_CASK_OPTS"] || "") + args
|
exclude_regex = /^\-\-#{Regexp.union(*Config::DEFAULT_DIRS.keys.map(&Regexp.public_method(:escape)))}=/
|
||||||
|
|
||||||
|
all_args = Shellwords.shellsplit(ENV.fetch("HOMEBREW_CASK_OPTS", ""))
|
||||||
|
.reject { |arg| arg.match?(exclude_regex) } + args
|
||||||
|
|
||||||
non_options = []
|
non_options = []
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
require "cask/config"
|
||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
class Cmd
|
class Cmd
|
||||||
class Upgrade < AbstractCommand
|
class Upgrade < AbstractCommand
|
||||||
@ -44,13 +46,17 @@ module Cask
|
|||||||
|
|
||||||
old_cask = CaskLoader.load(old_cask.installed_caskfile)
|
old_cask = CaskLoader.load(old_cask.installed_caskfile)
|
||||||
|
|
||||||
|
old_config = old_cask.config
|
||||||
|
|
||||||
old_cask_installer =
|
old_cask_installer =
|
||||||
Installer.new(old_cask, binaries: binaries?,
|
Installer.new(old_cask, binaries: binaries?,
|
||||||
verbose: verbose?,
|
verbose: verbose?,
|
||||||
force: force?,
|
force: force?,
|
||||||
upgrade: true)
|
upgrade: true)
|
||||||
|
|
||||||
new_cask = CaskLoader.load(old_cask.to_s)
|
new_cask = CaskLoader.load(old_cask.token)
|
||||||
|
|
||||||
|
new_cask.config = Config.global.merge(old_config)
|
||||||
|
|
||||||
new_cask_installer =
|
new_cask_installer =
|
||||||
Installer.new(new_cask, binaries: binaries?,
|
Installer.new(new_cask, binaries: binaries?,
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
|
require "json"
|
||||||
|
|
||||||
|
require "extend/hash_validator"
|
||||||
|
using HashValidator
|
||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
class Config
|
class Config
|
||||||
def self.global
|
DEFAULT_DIRS = {
|
||||||
@global ||= new
|
|
||||||
end
|
|
||||||
|
|
||||||
attr_reader :binarydir
|
|
||||||
|
|
||||||
def initialize(
|
|
||||||
appdir: "/Applications",
|
appdir: "/Applications",
|
||||||
prefpanedir: "~/Library/PreferencePanes",
|
prefpanedir: "~/Library/PreferencePanes",
|
||||||
qlplugindir: "~/Library/QuickLook",
|
qlplugindir: "~/Library/QuickLook",
|
||||||
@ -19,47 +18,91 @@ module Cask
|
|||||||
audio_unit_plugindir: "~/Library/Audio/Plug-Ins/Components",
|
audio_unit_plugindir: "~/Library/Audio/Plug-Ins/Components",
|
||||||
vst_plugindir: "~/Library/Audio/Plug-Ins/VST",
|
vst_plugindir: "~/Library/Audio/Plug-Ins/VST",
|
||||||
vst3_plugindir: "~/Library/Audio/Plug-Ins/VST3",
|
vst3_plugindir: "~/Library/Audio/Plug-Ins/VST3",
|
||||||
screen_saverdir: "~/Library/Screen Savers"
|
screen_saverdir: "~/Library/Screen Savers",
|
||||||
)
|
}.freeze
|
||||||
|
|
||||||
self.appdir = appdir
|
def self.global
|
||||||
self.prefpanedir = prefpanedir
|
@global ||= new
|
||||||
self.qlplugindir = qlplugindir
|
|
||||||
self.dictionarydir = dictionarydir
|
|
||||||
self.fontdir = fontdir
|
|
||||||
self.colorpickerdir = colorpickerdir
|
|
||||||
self.servicedir = servicedir
|
|
||||||
self.input_methoddir = input_methoddir
|
|
||||||
self.internet_plugindir = internet_plugindir
|
|
||||||
self.audio_unit_plugindir = audio_unit_plugindir
|
|
||||||
self.vst_plugindir = vst_plugindir
|
|
||||||
self.vst3_plugindir = vst3_plugindir
|
|
||||||
self.screen_saverdir = screen_saverdir
|
|
||||||
|
|
||||||
# `binarydir` is not customisable.
|
|
||||||
@binarydir = HOMEBREW_PREFIX/"bin"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
[
|
def self.clear
|
||||||
:appdir,
|
@global = nil
|
||||||
:prefpanedir,
|
end
|
||||||
:qlplugindir,
|
|
||||||
:dictionarydir,
|
def self.for_cask(cask)
|
||||||
:fontdir,
|
if cask.config_path.exist?
|
||||||
:colorpickerdir,
|
from_file(cask.config_path)
|
||||||
:servicedir,
|
else
|
||||||
:input_methoddir,
|
global
|
||||||
:internet_plugindir,
|
end
|
||||||
:audio_unit_plugindir,
|
end
|
||||||
:vst_plugindir,
|
|
||||||
:vst3_plugindir,
|
def self.from_file(path)
|
||||||
:screen_saverdir,
|
config = begin
|
||||||
].each do |dir|
|
JSON.parse(File.read(path))
|
||||||
attr_reader dir
|
rescue JSON::ParserError => e
|
||||||
|
raise e, "Cannot parse #{path}: #{e}", e.backtrace
|
||||||
|
end
|
||||||
|
|
||||||
|
new(
|
||||||
|
default: config.fetch("default", {}),
|
||||||
|
env: config.fetch("env", {}),
|
||||||
|
explicit: config.fetch("explicit", {}),
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.canonicalize(config)
|
||||||
|
config.map { |k, v| [k.to_sym, Pathname(v).expand_path] }.to_h
|
||||||
|
end
|
||||||
|
|
||||||
|
attr_accessor :explicit
|
||||||
|
|
||||||
|
def initialize(default: nil, env: nil, explicit: {})
|
||||||
|
@default = self.class.canonicalize(default) if default
|
||||||
|
@env = self.class.canonicalize(env) if env
|
||||||
|
@explicit = self.class.canonicalize(explicit)
|
||||||
|
|
||||||
|
@env&.assert_valid_keys!(*DEFAULT_DIRS.keys)
|
||||||
|
@explicit.assert_valid_keys!(*DEFAULT_DIRS.keys)
|
||||||
|
end
|
||||||
|
|
||||||
|
def default
|
||||||
|
@default ||= self.class.canonicalize(DEFAULT_DIRS)
|
||||||
|
end
|
||||||
|
|
||||||
|
def env
|
||||||
|
@env ||= self.class.canonicalize(
|
||||||
|
Shellwords.shellsplit(ENV.fetch("HOMEBREW_CASK_OPTS", ""))
|
||||||
|
.select { |arg| arg.include?("=") }
|
||||||
|
.map { |arg| arg.split("=", 2) }
|
||||||
|
.map { |(flag, value)| [flag.sub(/^\-\-/, ""), value] },
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def binarydir
|
||||||
|
@binarydir ||= HOMEBREW_PREFIX/"bin"
|
||||||
|
end
|
||||||
|
|
||||||
|
DEFAULT_DIRS.keys.each do |dir|
|
||||||
|
define_method(dir) do
|
||||||
|
explicit.fetch(dir, env.fetch(dir, default.fetch(dir)))
|
||||||
|
end
|
||||||
|
|
||||||
define_method(:"#{dir}=") do |path|
|
define_method(:"#{dir}=") do |path|
|
||||||
instance_variable_set(:"@#{dir}", Pathname(path).expand_path)
|
explicit[dir] = Pathname(path).expand_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def merge(other)
|
||||||
|
self.class.new(explicit: other.explicit.merge(explicit))
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_json(*args)
|
||||||
|
{
|
||||||
|
default: default,
|
||||||
|
env: env,
|
||||||
|
explicit: explicit,
|
||||||
|
}.to_json(*args)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -57,7 +57,6 @@ module Cask
|
|||||||
:appcast,
|
:appcast,
|
||||||
:artifacts,
|
:artifacts,
|
||||||
:auto_updates,
|
:auto_updates,
|
||||||
:caskroom_path,
|
|
||||||
:caveats,
|
:caveats,
|
||||||
:conflicts_with,
|
:conflicts_with,
|
||||||
:container,
|
:container,
|
||||||
@ -226,7 +225,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def caskroom_path
|
def caskroom_path
|
||||||
@caskroom_path ||= Caskroom.path.join(token)
|
@cask.caskroom_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def staged_path
|
def staged_path
|
||||||
|
|||||||
@ -4,6 +4,7 @@ require "formula_installer"
|
|||||||
require "unpack_strategy"
|
require "unpack_strategy"
|
||||||
|
|
||||||
require "cask/cask_dependencies"
|
require "cask/cask_dependencies"
|
||||||
|
require "cask/config"
|
||||||
require "cask/download"
|
require "cask/download"
|
||||||
require "cask/staged"
|
require "cask/staged"
|
||||||
require "cask/verify"
|
require "cask/verify"
|
||||||
@ -39,7 +40,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
attr_predicate :binaries?, :force?, :skip_cask_deps?, :require_sha?,
|
attr_predicate :binaries?, :force?, :skip_cask_deps?, :require_sha?,
|
||||||
:upgrade?, :verbose?, :installed_as_dependency?,
|
:reinstall?, :upgrade?, :verbose?, :installed_as_dependency?,
|
||||||
:quarantine?
|
:quarantine?
|
||||||
|
|
||||||
def self.print_caveats(cask)
|
def self.print_caveats(cask)
|
||||||
@ -79,7 +80,9 @@ module Cask
|
|||||||
def install
|
def install
|
||||||
odebug "Cask::Installer#install"
|
odebug "Cask::Installer#install"
|
||||||
|
|
||||||
if @cask.installed? && !force? && !@reinstall && !upgrade?
|
old_config = @cask.config
|
||||||
|
|
||||||
|
if @cask.installed? && !force? && !reinstall? && !upgrade?
|
||||||
raise CaskAlreadyInstalledError, @cask
|
raise CaskAlreadyInstalledError, @cask
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -87,11 +90,14 @@ module Cask
|
|||||||
|
|
||||||
print_caveats
|
print_caveats
|
||||||
fetch
|
fetch
|
||||||
uninstall_existing_cask if @reinstall
|
uninstall_existing_cask if reinstall?
|
||||||
|
|
||||||
oh1 "Installing Cask #{Formatter.identifier(@cask)}"
|
oh1 "Installing Cask #{Formatter.identifier(@cask)}"
|
||||||
opoo "macOS's Gatekeeper has been disabled for this Cask" unless quarantine?
|
opoo "macOS's Gatekeeper has been disabled for this Cask" unless quarantine?
|
||||||
stage
|
stage
|
||||||
|
|
||||||
|
@cask.config = Config.global.merge(old_config)
|
||||||
|
|
||||||
install_artifacts
|
install_artifacts
|
||||||
|
|
||||||
unless @cask.tap&.private?
|
unless @cask.tap&.private?
|
||||||
@ -209,6 +215,8 @@ module Cask
|
|||||||
artifact.install_phase(command: @command, verbose: verbose?, force: force?)
|
artifact.install_phase(command: @command, verbose: verbose?, force: force?)
|
||||||
already_installed_artifacts.unshift(artifact)
|
already_installed_artifacts.unshift(artifact)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
save_config_file
|
||||||
rescue => e
|
rescue => e
|
||||||
begin
|
begin
|
||||||
already_installed_artifacts.each do |artifact|
|
already_installed_artifacts.each do |artifact|
|
||||||
@ -382,13 +390,23 @@ module Cask
|
|||||||
old_savedir&.rmtree
|
old_savedir&.rmtree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def save_config_file
|
||||||
|
@cask.config_path.atomic_write(@cask.config.to_json)
|
||||||
|
end
|
||||||
|
|
||||||
def uninstall
|
def uninstall
|
||||||
oh1 "Uninstalling Cask #{Formatter.identifier(@cask)}"
|
oh1 "Uninstalling Cask #{Formatter.identifier(@cask)}"
|
||||||
uninstall_artifacts(clear: true)
|
uninstall_artifacts(clear: true)
|
||||||
|
remove_config_file unless reinstall? || upgrade?
|
||||||
purge_versioned_files
|
purge_versioned_files
|
||||||
purge_caskroom_path if force?
|
purge_caskroom_path if force?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_config_file
|
||||||
|
FileUtils.rm_f @cask.config_path
|
||||||
|
@cask.config_path.parent.rmdir_if_possible
|
||||||
|
end
|
||||||
|
|
||||||
def start_upgrade
|
def start_upgrade
|
||||||
oh1 "Starting upgrade for Cask #{Formatter.identifier(@cask)}"
|
oh1 "Starting upgrade for Cask #{Formatter.identifier(@cask)}"
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ describe Cask::Artifact::App, :cask do
|
|||||||
}
|
}
|
||||||
|
|
||||||
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
||||||
let(:target_path) { Cask::Config.global.appdir.join("AnotherName.app") }
|
let(:target_path) { cask.config.appdir.join("AnotherName.app") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
InstallHelper.install_without_artifacts(cask)
|
InstallHelper.install_without_artifacts(cask)
|
||||||
@ -58,7 +58,7 @@ describe Cask::Artifact::App, :cask do
|
|||||||
expect(target_path).to be_a_directory
|
expect(target_path).to be_a_directory
|
||||||
expect(source_path).not_to exist
|
expect(source_path).not_to exist
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine Deluxe.app")).not_to exist
|
expect(cask.config.appdir.join("Caffeine Deluxe.app")).not_to exist
|
||||||
expect(cask.staged_path.join("Caffeine Deluxe.app")).to be_a_directory
|
expect(cask.staged_path.join("Caffeine Deluxe.app")).to be_a_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ describe Cask::Artifact::App, :cask do
|
|||||||
let(:app) { cask.artifacts.find { |a| a.is_a?(described_class) } }
|
let(:app) { cask.artifacts.find { |a| a.is_a?(described_class) } }
|
||||||
|
|
||||||
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
||||||
let(:target_path) { Cask::Config.global.appdir.join("Caffeine.app") }
|
let(:target_path) { cask.config.appdir.join("Caffeine.app") }
|
||||||
|
|
||||||
let(:install_phase) { app.install_phase(command: command, force: force) }
|
let(:install_phase) { app.install_phase(command: command, force: force) }
|
||||||
let(:uninstall_phase) { app.uninstall_phase(command: command, force: force) }
|
let(:uninstall_phase) { app.uninstall_phase(command: command, force: force) }
|
||||||
@ -53,7 +53,7 @@ describe Cask::Artifact::App, :cask do
|
|||||||
expect(target_path).to be_a_directory
|
expect(target_path).to be_a_directory
|
||||||
expect(source_path).not_to exist
|
expect(source_path).not_to exist
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine Deluxe.app")).not_to exist
|
expect(cask.config.appdir.join("Caffeine Deluxe.app")).not_to exist
|
||||||
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
|
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ describe Cask::Artifact::Binary, :cask do
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
let(:artifacts) { cask.artifacts.select { |a| a.is_a?(described_class) } }
|
let(:artifacts) { cask.artifacts.select { |a| a.is_a?(described_class) } }
|
||||||
let(:expected_path) { Cask::Config.global.binarydir.join("binary") }
|
let(:expected_path) { cask.config.binarydir.join("binary") }
|
||||||
|
|
||||||
after do
|
after do
|
||||||
FileUtils.rm expected_path if expected_path.exist?
|
FileUtils.rm expected_path if expected_path.exist?
|
||||||
@ -38,7 +38,7 @@ describe Cask::Artifact::Binary, :cask do
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
let(:expected_path) { Cask::Config.global.binarydir.join("naked_non_executable") }
|
let(:expected_path) { cask.config.binarydir.join("naked_non_executable") }
|
||||||
|
|
||||||
it "makes the binary executable" do
|
it "makes the binary executable" do
|
||||||
expect(FileUtils).to receive(:chmod)
|
expect(FileUtils).to receive(:chmod)
|
||||||
|
|||||||
@ -10,7 +10,7 @@ describe Cask::Artifact::Artifact, :cask do
|
|||||||
}
|
}
|
||||||
|
|
||||||
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
let(:source_path) { cask.staged_path.join("Caffeine.app") }
|
||||||
let(:target_path) { Cask::Config.global.appdir.join("Caffeine.app") }
|
let(:target_path) { cask.config.appdir.join("Caffeine.app") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
InstallHelper.install_without_artifacts(cask)
|
InstallHelper.install_without_artifacts(cask)
|
||||||
|
|||||||
@ -2,7 +2,7 @@ describe Cask::Artifact::Installer, :cask do
|
|||||||
subject(:installer) { described_class.new(cask, **args) }
|
subject(:installer) { described_class.new(cask, **args) }
|
||||||
|
|
||||||
let(:staged_path) { mktmpdir }
|
let(:staged_path) { mktmpdir }
|
||||||
let(:cask) { instance_double(Cask::Cask, staged_path: staged_path, config: nil) }
|
let(:cask) { instance_double(Cask::Cask, staged_path: staged_path) }
|
||||||
|
|
||||||
let(:command) { SystemCommand }
|
let(:command) { SystemCommand }
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ describe Cask::Artifact::Suite, :cask do
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
let(:target_path) { Cask::Config.global.appdir.join("Caffeine") }
|
let(:target_path) { cask.config.appdir.join("Caffeine") }
|
||||||
let(:source_path) { cask.staged_path.join("Caffeine") }
|
let(:source_path) { cask.staged_path.join("Caffeine") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|||||||
@ -11,10 +11,10 @@ describe Cask::Artifact::App, :cask do
|
|||||||
}
|
}
|
||||||
|
|
||||||
let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") }
|
let(:source_path_mini) { cask.staged_path.join("Caffeine Mini.app") }
|
||||||
let(:target_path_mini) { Cask::Config.global.appdir.join("Caffeine Mini.app") }
|
let(:target_path_mini) { cask.config.appdir.join("Caffeine Mini.app") }
|
||||||
|
|
||||||
let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") }
|
let(:source_path_pro) { cask.staged_path.join("Caffeine Pro.app") }
|
||||||
let(:target_path_pro) { Cask::Config.global.appdir.join("Caffeine Pro.app") }
|
let(:target_path_pro) { cask.config.appdir.join("Caffeine Pro.app") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
InstallHelper.install_without_artifacts(cask)
|
InstallHelper.install_without_artifacts(cask)
|
||||||
@ -52,7 +52,7 @@ describe Cask::Artifact::App, :cask do
|
|||||||
expect(target_path_mini).to be_a_directory
|
expect(target_path_mini).to be_a_directory
|
||||||
expect(source_path_mini).not_to exist
|
expect(source_path_mini).not_to exist
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine Deluxe.app")).not_to exist
|
expect(cask.config.appdir.join("Caffeine Deluxe.app")).not_to exist
|
||||||
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
|
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
require_relative "shared_examples/invalid_option"
|
require_relative "shared_examples/invalid_option"
|
||||||
|
|
||||||
describe Cask::Cmd::Audit, :cask do
|
describe Cask::Cmd::Audit, :cask do
|
||||||
let(:cask) { Cask::Cask.new(nil) }
|
let(:cask) { Cask::Cask.new("cask") }
|
||||||
|
|
||||||
it_behaves_like "a command that handles invalid options"
|
it_behaves_like "a command that handles invalid options"
|
||||||
|
|
||||||
|
|||||||
@ -21,11 +21,12 @@ describe Cask::Cmd::Install, :cask do
|
|||||||
|
|
||||||
it "allows staging and activation of multiple Casks at once" do
|
it "allows staging and activation of multiple Casks at once" do
|
||||||
described_class.run("local-transmission", "local-caffeine")
|
described_class.run("local-transmission", "local-caffeine")
|
||||||
|
transmission = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||||
expect(Cask::CaskLoader.load(cask_path("local-transmission"))).to be_installed
|
caffeine = Cask::CaskLoader.load(cask_path("local-caffeine"))
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).to be_a_directory
|
expect(transmission).to be_installed
|
||||||
expect(Cask::CaskLoader.load(cask_path("local-caffeine"))).to be_installed
|
expect(transmission.config.appdir.join("Transmission.app")).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine.app")).to be_a_directory
|
expect(caffeine).to be_installed
|
||||||
|
expect(caffeine.config.appdir.join("Caffeine.app")).to be_a_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
it "skips double install (without nuking existing installation)" do
|
it "skips double install (without nuking existing installation)" do
|
||||||
|
|||||||
@ -80,9 +80,9 @@ describe Cask::Cmd::List, :cask do
|
|||||||
described_class.run("local-transmission", "local-caffeine")
|
described_class.run("local-transmission", "local-caffeine")
|
||||||
}.to output(<<~EOS).to_stdout
|
}.to output(<<~EOS).to_stdout
|
||||||
==> Apps
|
==> Apps
|
||||||
#{Cask::Config.global.appdir.join("Transmission.app")} (#{Cask::Config.global.appdir.join("Transmission.app").abv})
|
#{transmission.config.appdir.join("Transmission.app")} (#{transmission.config.appdir.join("Transmission.app").abv})
|
||||||
==> Apps
|
==> Apps
|
||||||
Missing App: #{Cask::Config.global.appdir.join("Caffeine.app")}
|
Missing App: #{caffeine.config.appdir.join("Caffeine.app")}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,15 +1,11 @@
|
|||||||
describe Cask::Cmd, :cask do
|
describe Cask::Cmd, :cask do
|
||||||
it "supports setting the appdir" do
|
it "supports setting the appdir" do
|
||||||
allow(Cask::Config.global).to receive(:appdir).and_call_original
|
|
||||||
|
|
||||||
described_class.new.process_options("help", "--appdir=/some/path/foo")
|
described_class.new.process_options("help", "--appdir=/some/path/foo")
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir).to eq(Pathname.new("/some/path/foo"))
|
expect(Cask::Config.global.appdir).to eq(Pathname.new("/some/path/foo"))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the appdir from ENV" do
|
it "supports setting the appdir from ENV" do
|
||||||
allow(Cask::Config.global).to receive(:appdir).and_call_original
|
|
||||||
|
|
||||||
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/some/path/bar"
|
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/some/path/bar"
|
||||||
|
|
||||||
described_class.new.process_options("help")
|
described_class.new.process_options("help")
|
||||||
@ -18,16 +14,12 @@ describe Cask::Cmd, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the prefpanedir" do
|
it "supports setting the prefpanedir" do
|
||||||
allow(Cask::Config.global).to receive(:prefpanedir).and_call_original
|
|
||||||
|
|
||||||
described_class.new.process_options("help", "--prefpanedir=/some/path/foo")
|
described_class.new.process_options("help", "--prefpanedir=/some/path/foo")
|
||||||
|
|
||||||
expect(Cask::Config.global.prefpanedir).to eq(Pathname.new("/some/path/foo"))
|
expect(Cask::Config.global.prefpanedir).to eq(Pathname.new("/some/path/foo"))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the prefpanedir from ENV" do
|
it "supports setting the prefpanedir from ENV" do
|
||||||
allow(Cask::Config.global).to receive(:prefpanedir).and_call_original
|
|
||||||
|
|
||||||
ENV["HOMEBREW_CASK_OPTS"] = "--prefpanedir=/some/path/bar"
|
ENV["HOMEBREW_CASK_OPTS"] = "--prefpanedir=/some/path/bar"
|
||||||
|
|
||||||
described_class.new.process_options("help")
|
described_class.new.process_options("help")
|
||||||
@ -36,16 +28,12 @@ describe Cask::Cmd, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the qlplugindir" do
|
it "supports setting the qlplugindir" do
|
||||||
allow(Cask::Config.global).to receive(:qlplugindir).and_call_original
|
|
||||||
|
|
||||||
described_class.new.process_options("help", "--qlplugindir=/some/path/foo")
|
described_class.new.process_options("help", "--qlplugindir=/some/path/foo")
|
||||||
|
|
||||||
expect(Cask::Config.global.qlplugindir).to eq(Pathname.new("/some/path/foo"))
|
expect(Cask::Config.global.qlplugindir).to eq(Pathname.new("/some/path/foo"))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the qlplugindir from ENV" do
|
it "supports setting the qlplugindir from ENV" do
|
||||||
allow(Cask::Config.global).to receive(:qlplugindir).and_call_original
|
|
||||||
|
|
||||||
ENV["HOMEBREW_CASK_OPTS"] = "--qlplugindir=/some/path/bar"
|
ENV["HOMEBREW_CASK_OPTS"] = "--qlplugindir=/some/path/bar"
|
||||||
|
|
||||||
described_class.new.process_options("help")
|
described_class.new.process_options("help")
|
||||||
@ -54,16 +42,12 @@ describe Cask::Cmd, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the colorpickerdir" do
|
it "supports setting the colorpickerdir" do
|
||||||
allow(Cask::Config.global).to receive(:colorpickerdir).and_call_original
|
|
||||||
|
|
||||||
described_class.new.process_options("help", "--colorpickerdir=/some/path/foo")
|
described_class.new.process_options("help", "--colorpickerdir=/some/path/foo")
|
||||||
|
|
||||||
expect(Cask::Config.global.colorpickerdir).to eq(Pathname.new("/some/path/foo"))
|
expect(Cask::Config.global.colorpickerdir).to eq(Pathname.new("/some/path/foo"))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the colorpickerdir from ENV" do
|
it "supports setting the colorpickerdir from ENV" do
|
||||||
allow(Cask::Config.global).to receive(:colorpickerdir).and_call_original
|
|
||||||
|
|
||||||
ENV["HOMEBREW_CASK_OPTS"] = "--colorpickerdir=/some/path/bar"
|
ENV["HOMEBREW_CASK_OPTS"] = "--colorpickerdir=/some/path/bar"
|
||||||
|
|
||||||
described_class.new.process_options("help")
|
described_class.new.process_options("help")
|
||||||
@ -72,16 +56,12 @@ describe Cask::Cmd, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the dictionarydir" do
|
it "supports setting the dictionarydir" do
|
||||||
allow(Cask::Config.global).to receive(:dictionarydir).and_call_original
|
|
||||||
|
|
||||||
described_class.new.process_options("help", "--dictionarydir=/some/path/foo")
|
described_class.new.process_options("help", "--dictionarydir=/some/path/foo")
|
||||||
|
|
||||||
expect(Cask::Config.global.dictionarydir).to eq(Pathname.new("/some/path/foo"))
|
expect(Cask::Config.global.dictionarydir).to eq(Pathname.new("/some/path/foo"))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the dictionarydir from ENV" do
|
it "supports setting the dictionarydir from ENV" do
|
||||||
allow(Cask::Config.global).to receive(:dictionarydir).and_call_original
|
|
||||||
|
|
||||||
ENV["HOMEBREW_CASK_OPTS"] = "--dictionarydir=/some/path/bar"
|
ENV["HOMEBREW_CASK_OPTS"] = "--dictionarydir=/some/path/bar"
|
||||||
|
|
||||||
described_class.new.process_options("help")
|
described_class.new.process_options("help")
|
||||||
@ -90,16 +70,12 @@ describe Cask::Cmd, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the fontdir" do
|
it "supports setting the fontdir" do
|
||||||
allow(Cask::Config.global).to receive(:fontdir).and_call_original
|
|
||||||
|
|
||||||
described_class.new.process_options("help", "--fontdir=/some/path/foo")
|
described_class.new.process_options("help", "--fontdir=/some/path/foo")
|
||||||
|
|
||||||
expect(Cask::Config.global.fontdir).to eq(Pathname.new("/some/path/foo"))
|
expect(Cask::Config.global.fontdir).to eq(Pathname.new("/some/path/foo"))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the fontdir from ENV" do
|
it "supports setting the fontdir from ENV" do
|
||||||
allow(Cask::Config.global).to receive(:fontdir).and_call_original
|
|
||||||
|
|
||||||
ENV["HOMEBREW_CASK_OPTS"] = "--fontdir=/some/path/bar"
|
ENV["HOMEBREW_CASK_OPTS"] = "--fontdir=/some/path/bar"
|
||||||
|
|
||||||
described_class.new.process_options("help")
|
described_class.new.process_options("help")
|
||||||
@ -108,16 +84,12 @@ describe Cask::Cmd, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the servicedir" do
|
it "supports setting the servicedir" do
|
||||||
allow(Cask::Config.global).to receive(:servicedir).and_call_original
|
|
||||||
|
|
||||||
described_class.new.process_options("help", "--servicedir=/some/path/foo")
|
described_class.new.process_options("help", "--servicedir=/some/path/foo")
|
||||||
|
|
||||||
expect(Cask::Config.global.servicedir).to eq(Pathname.new("/some/path/foo"))
|
expect(Cask::Config.global.servicedir).to eq(Pathname.new("/some/path/foo"))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the servicedir from ENV" do
|
it "supports setting the servicedir from ENV" do
|
||||||
allow(Cask::Config.global).to receive(:servicedir).and_call_original
|
|
||||||
|
|
||||||
ENV["HOMEBREW_CASK_OPTS"] = "--servicedir=/some/path/bar"
|
ENV["HOMEBREW_CASK_OPTS"] = "--servicedir=/some/path/bar"
|
||||||
|
|
||||||
described_class.new.process_options("help")
|
described_class.new.process_options("help")
|
||||||
@ -126,8 +98,6 @@ describe Cask::Cmd, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "allows additional options to be passed through" do
|
it "allows additional options to be passed through" do
|
||||||
allow(Cask::Config.global).to receive(:appdir).and_call_original
|
|
||||||
|
|
||||||
rest = described_class.new.process_options("edit", "foo", "--create", "--appdir=/some/path/qux")
|
rest = described_class.new.process_options("edit", "foo", "--create", "--appdir=/some/path/qux")
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir).to eq(Pathname.new("/some/path/qux"))
|
expect(Cask::Config.global.appdir).to eq(Pathname.new("/some/path/qux"))
|
||||||
|
|||||||
@ -51,9 +51,9 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
described_class.run("local-caffeine", "local-transmission")
|
described_class.run("local-caffeine", "local-transmission")
|
||||||
|
|
||||||
expect(caffeine).not_to be_installed
|
expect(caffeine).not_to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).not_to exist
|
expect(caffeine.config.appdir.join("Transmission.app")).not_to exist
|
||||||
expect(transmission).not_to be_installed
|
expect(transmission).not_to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine.app")).not_to exist
|
expect(transmission.config.appdir.join("Caffeine.app")).not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls `uninstall` before removing artifacts" do
|
it "calls `uninstall` before removing artifacts" do
|
||||||
@ -69,7 +69,7 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
}.not_to raise_error
|
}.not_to raise_error
|
||||||
|
|
||||||
expect(cask).not_to be_installed
|
expect(cask).not_to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("MyFancyApp.app")).not_to exist
|
expect(cask.config.appdir.join("MyFancyApp.app")).not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can uninstall Casks when the uninstall script is missing, but only when using `--force`" do
|
it "can uninstall Casks when the uninstall script is missing, but only when using `--force`" do
|
||||||
@ -79,7 +79,7 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
|
|
||||||
expect(cask).to be_installed
|
expect(cask).to be_installed
|
||||||
|
|
||||||
Cask::Config.global.appdir.join("MyFancyApp.app").rmtree
|
cask.config.appdir.join("MyFancyApp.app").rmtree
|
||||||
|
|
||||||
expect { described_class.run("with-uninstall-script-app") }
|
expect { described_class.run("with-uninstall-script-app") }
|
||||||
.to raise_error(Cask::CaskError, /uninstall script .* does not exist/)
|
.to raise_error(Cask::CaskError, /uninstall script .* does not exist/)
|
||||||
|
|||||||
@ -147,7 +147,7 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
|
|
||||||
it 'does not include the Casks with "auto_updates true" when the version did not change' do
|
it 'does not include the Casks with "auto_updates true" when the version did not change' do
|
||||||
cask = Cask::CaskLoader.load("auto-updates")
|
cask = Cask::CaskLoader.load("auto-updates")
|
||||||
cask_path = Cask::Config.global.appdir.join("MyFancyApp.app")
|
cask_path = cask.config.appdir.join("MyFancyApp.app")
|
||||||
|
|
||||||
expect(cask).to be_installed
|
expect(cask).to be_installed
|
||||||
expect(cask_path).to be_a_directory
|
expect(cask_path).to be_a_directory
|
||||||
@ -188,7 +188,7 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
|
|
||||||
it "restores the old Cask if the upgrade failed" do
|
it "restores the old Cask if the upgrade failed" do
|
||||||
will_fail_if_upgraded = Cask::CaskLoader.load("will-fail-if-upgraded")
|
will_fail_if_upgraded = Cask::CaskLoader.load("will-fail-if-upgraded")
|
||||||
will_fail_if_upgraded_path = Cask::Config.global.appdir.join("container")
|
will_fail_if_upgraded_path = will_fail_if_upgraded.config.appdir.join("container")
|
||||||
|
|
||||||
expect(will_fail_if_upgraded).to be_installed
|
expect(will_fail_if_upgraded).to be_installed
|
||||||
expect(will_fail_if_upgraded_path).to be_a_file
|
expect(will_fail_if_upgraded_path).to be_a_file
|
||||||
@ -206,7 +206,7 @@ describe Cask::Cmd::Upgrade, :cask do
|
|||||||
|
|
||||||
it "does not restore the old Cask if the upgrade failed pre-install" do
|
it "does not restore the old Cask if the upgrade failed pre-install" do
|
||||||
bad_checksum = Cask::CaskLoader.load("bad-checksum")
|
bad_checksum = Cask::CaskLoader.load("bad-checksum")
|
||||||
bad_checksum_path = Cask::Config.global.appdir.join("Caffeine.app")
|
bad_checksum_path = bad_checksum.config.appdir.join("Caffeine.app")
|
||||||
|
|
||||||
expect(bad_checksum).to be_installed
|
expect(bad_checksum).to be_installed
|
||||||
expect(bad_checksum_path).to be_a_directory
|
expect(bad_checksum_path).to be_a_directory
|
||||||
|
|||||||
@ -23,8 +23,8 @@ describe Cask::Cmd::Zap, :cask do
|
|||||||
described_class.run("local-caffeine", "local-transmission")
|
described_class.run("local-caffeine", "local-transmission")
|
||||||
|
|
||||||
expect(caffeine).not_to be_installed
|
expect(caffeine).not_to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine.app")).not_to be_a_symlink
|
expect(caffeine.config.appdir.join("Caffeine.app")).not_to be_a_symlink
|
||||||
expect(transmission).not_to be_installed
|
expect(transmission).not_to be_installed
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).not_to be_a_symlink
|
expect(transmission.config.appdir.join("Transmission.app")).not_to be_a_symlink
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -56,9 +56,7 @@ describe Cask::Cmd, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "respects the env variable when choosing what appdir to create" do
|
it "respects the env variable when choosing what appdir to create" do
|
||||||
allow(ENV).to receive(:[]).and_call_original
|
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/custom/appdir"
|
||||||
allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--appdir=/custom/appdir")
|
|
||||||
allow(Cask::Config.global).to receive(:appdir).and_call_original
|
|
||||||
|
|
||||||
described_class.run("noop")
|
described_class.run("noop")
|
||||||
|
|
||||||
|
|||||||
51
Library/Homebrew/test/cask/config_spec.rb
Normal file
51
Library/Homebrew/test/cask/config_spec.rb
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
describe Cask::Config, :cask do
|
||||||
|
subject(:config) { described_class.new }
|
||||||
|
|
||||||
|
describe "#default" do
|
||||||
|
it "returns the default directories" do
|
||||||
|
expect(config.default[:appdir]).to eq(Pathname(TEST_TMPDIR).join("cask-appdir"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#appdir" do
|
||||||
|
it "returns the default value if no HOMEBREW_CASK_OPTS is unset" do
|
||||||
|
expect(config.appdir).to eq(Pathname(TEST_TMPDIR).join("cask-appdir"))
|
||||||
|
end
|
||||||
|
|
||||||
|
specify "environment overwrites default" do
|
||||||
|
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/path/to/apps"
|
||||||
|
|
||||||
|
expect(config.appdir).to eq(Pathname("/path/to/apps"))
|
||||||
|
end
|
||||||
|
|
||||||
|
specify "specific overwrites default" do
|
||||||
|
config = described_class.new(explicit: { appdir: "/explicit/path/to/apps" })
|
||||||
|
|
||||||
|
expect(config.appdir).to eq(Pathname("/explicit/path/to/apps"))
|
||||||
|
end
|
||||||
|
|
||||||
|
specify "explicit overwrites environment" do
|
||||||
|
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/path/to/apps"
|
||||||
|
|
||||||
|
config = described_class.new(explicit: { appdir: "/explicit/path/to/apps" })
|
||||||
|
|
||||||
|
expect(config.appdir).to eq(Pathname("/explicit/path/to/apps"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#env" do
|
||||||
|
it "returns directories specified with the HOMEBREW_CASK_OPTS variable" do
|
||||||
|
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/path/to/apps"
|
||||||
|
|
||||||
|
expect(config.env).to eq(appdir: Pathname("/path/to/apps"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#explicit" do
|
||||||
|
let(:config) { described_class.new(explicit: { appdir: "/explicit/path/to/apps" }) }
|
||||||
|
|
||||||
|
it "returns directories explicitly given as arguments" do
|
||||||
|
expect(config.explicit[:appdir]).to eq(Pathname("/explicit/path/to/apps"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -468,7 +468,7 @@ describe Cask::DSL, :cask do
|
|||||||
let(:token) { "appdir-interpolation" }
|
let(:token) { "appdir-interpolation" }
|
||||||
|
|
||||||
it "is allowed" do
|
it "is allowed" do
|
||||||
expect(cask.artifacts.first.source).to eq(Cask::Config.global.appdir/"some/path")
|
expect(cask.artifacts.first.source).to eq(cask.config.appdir/"some/path")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(caffeine).install
|
Cask::Installer.new(caffeine).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("local-caffeine", caffeine.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("local-caffeine", caffeine.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("Caffeine.app")).to be_a_directory
|
expect(caffeine.config.appdir.join("Caffeine.app")).to be_a_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with dmg-based Casks" do
|
it "works with dmg-based Casks" do
|
||||||
@ -19,7 +19,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(asset).install
|
Cask::Installer.new(asset).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("container-dmg", asset.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("container-dmg", asset.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_a_file
|
expect(asset.config.appdir.join("container")).to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with tar-gz-based Casks" do
|
it "works with tar-gz-based Casks" do
|
||||||
@ -28,7 +28,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(asset).install
|
Cask::Installer.new(asset).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("container-tar-gz", asset.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("container-tar-gz", asset.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_a_file
|
expect(asset.config.appdir.join("container")).to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with xar-based Casks" do
|
it "works with xar-based Casks" do
|
||||||
@ -37,7 +37,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(asset).install
|
Cask::Installer.new(asset).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("container-xar", asset.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("container-xar", asset.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_a_file
|
expect(asset.config.appdir.join("container")).to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with pure bzip2-based Casks" do
|
it "works with pure bzip2-based Casks" do
|
||||||
@ -46,7 +46,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(asset).install
|
Cask::Installer.new(asset).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("container-bzip2", asset.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("container-bzip2", asset.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_a_file
|
expect(asset.config.appdir.join("container")).to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with pure gzip-based Casks" do
|
it "works with pure gzip-based Casks" do
|
||||||
@ -55,7 +55,7 @@ describe Cask::Installer, :cask do
|
|||||||
Cask::Installer.new(asset).install
|
Cask::Installer.new(asset).install
|
||||||
|
|
||||||
expect(Cask::Caskroom.path.join("container-gzip", asset.version)).to be_a_directory
|
expect(Cask::Caskroom.path.join("container-gzip", asset.version)).to be_a_directory
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_a_file
|
expect(asset.config.appdir.join("container")).to be_a_file
|
||||||
end
|
end
|
||||||
|
|
||||||
it "blows up on a bad checksum" do
|
it "blows up on a bad checksum" do
|
||||||
|
|||||||
@ -11,13 +11,11 @@ describe Cask::Quarantine, :cask do
|
|||||||
it "quarantines a nice fresh Cask" do
|
it "quarantines a nice fresh Cask" do
|
||||||
Cask::Cmd::Install.run("local-transmission")
|
Cask::Cmd::Install.run("local-transmission")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||||
Cask::CaskLoader.load(cask_path("local-transmission")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(
|
expect(cask).to be_installed
|
||||||
Cask::Config.global.appdir.join("Transmission.app"),
|
|
||||||
).to be_quarantined
|
expect(cask.config.appdir.join("Transmission.app")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines Cask fetches" do
|
it "quarantines Cask fetches" do
|
||||||
@ -42,83 +40,81 @@ describe Cask::Quarantine, :cask do
|
|||||||
|
|
||||||
Cask::Cmd::Install.run("local-transmission")
|
Cask::Cmd::Install.run("local-transmission")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||||
Cask::CaskLoader.load(cask_path("local-transmission")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("Transmission.app")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines dmg-based Casks" do
|
it "quarantines dmg-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-dmg")
|
Cask::Cmd::Install.run("container-dmg")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-dmg"))
|
||||||
Cask::CaskLoader.load(cask_path("container-dmg")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines tar-gz-based Casks" do
|
it "quarantines tar-gz-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-tar-gz")
|
Cask::Cmd::Install.run("container-tar-gz")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-tar-gz"))
|
||||||
Cask::CaskLoader.load(cask_path("container-tar-gz")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines xar-based Casks" do
|
it "quarantines xar-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-xar")
|
Cask::Cmd::Install.run("container-xar")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-xar"))
|
||||||
Cask::CaskLoader.load(cask_path("container-xar")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines pure bzip2-based Casks" do
|
it "quarantines pure bzip2-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-bzip2")
|
Cask::Cmd::Install.run("container-bzip2")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-bzip2"))
|
||||||
Cask::CaskLoader.load(cask_path("container-bzip2")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines pure gzip-based Casks" do
|
it "quarantines pure gzip-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-gzip")
|
Cask::Cmd::Install.run("container-gzip")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-gzip"))
|
||||||
Cask::CaskLoader.load(cask_path("container-gzip")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines the pkg in naked-pkg-based Casks" do
|
it "quarantines the pkg in naked-pkg-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-pkg")
|
Cask::Cmd::Install.run("container-pkg")
|
||||||
|
|
||||||
naked_pkg = Cask::CaskLoader.load(cask_path("container-pkg"))
|
cask = Cask::CaskLoader.load(cask_path("container-pkg"))
|
||||||
|
|
||||||
expect(naked_pkg).to be_installed
|
expect(cask).to be_installed
|
||||||
|
|
||||||
expect(
|
expect(cask.staged_path/"container.pkg").to be_quarantined
|
||||||
Cask::Caskroom.path.join("container-pkg", naked_pkg.version, "container.pkg"),
|
|
||||||
).to be_quarantined
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "quarantines a nested container" do
|
it "quarantines a nested container" do
|
||||||
Cask::Cmd::Install.run("nested-app")
|
Cask::Cmd::Install.run("nested-app")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("nested-app"))
|
||||||
Cask::CaskLoader.load(cask_path("nested-app")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("MyNestedApp.app")).to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("MyNestedApp.app")).to be_quarantined
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -126,11 +122,11 @@ describe Cask::Quarantine, :cask do
|
|||||||
it "does not quarantine even a nice, fresh Cask" do
|
it "does not quarantine even a nice, fresh Cask" do
|
||||||
Cask::Cmd::Install.run("local-transmission", "--no-quarantine")
|
Cask::Cmd::Install.run("local-transmission", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||||
Cask::CaskLoader.load(cask_path("local-transmission")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("Transmission.app")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine Cask fetches" do
|
it "does not quarantine Cask fetches" do
|
||||||
@ -155,61 +151,61 @@ describe Cask::Quarantine, :cask do
|
|||||||
|
|
||||||
Cask::Cmd::Install.run("local-transmission", "--no-quarantine")
|
Cask::Cmd::Install.run("local-transmission", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("local-transmission"))
|
||||||
Cask::CaskLoader.load(cask_path("local-transmission")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("Transmission.app")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("Transmission.app")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine dmg-based Casks" do
|
it "does not quarantine dmg-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-dmg", "--no-quarantine")
|
Cask::Cmd::Install.run("container-dmg", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-dmg"))
|
||||||
Cask::CaskLoader.load(cask_path("container-dmg")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine tar-gz-based Casks" do
|
it "does not quarantine tar-gz-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-tar-gz", "--no-quarantine")
|
Cask::Cmd::Install.run("container-tar-gz", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-tar-gz"))
|
||||||
Cask::CaskLoader.load(cask_path("container-tar-gz")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine xar-based Casks" do
|
it "does not quarantine xar-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-xar", "--no-quarantine")
|
Cask::Cmd::Install.run("container-xar", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-xar"))
|
||||||
Cask::CaskLoader.load(cask_path("container-xar")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine pure bzip2-based Casks" do
|
it "does not quarantine pure bzip2-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-bzip2", "--no-quarantine")
|
Cask::Cmd::Install.run("container-bzip2", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-bzip2"))
|
||||||
Cask::CaskLoader.load(cask_path("container-bzip2")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine pure gzip-based Casks" do
|
it "does not quarantine pure gzip-based Casks" do
|
||||||
Cask::Cmd::Install.run("container-gzip", "--no-quarantine")
|
Cask::Cmd::Install.run("container-gzip", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("container-gzip"))
|
||||||
Cask::CaskLoader.load(cask_path("container-gzip")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("container")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("container")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not quarantine the pkg in naked-pkg-based Casks" do
|
it "does not quarantine the pkg in naked-pkg-based Casks" do
|
||||||
@ -227,11 +223,11 @@ describe Cask::Quarantine, :cask do
|
|||||||
it "does not quarantine a nested container" do
|
it "does not quarantine a nested container" do
|
||||||
Cask::Cmd::Install.run("nested-app", "--no-quarantine")
|
Cask::Cmd::Install.run("nested-app", "--no-quarantine")
|
||||||
|
|
||||||
expect(
|
cask = Cask::CaskLoader.load(cask_path("nested-app"))
|
||||||
Cask::CaskLoader.load(cask_path("nested-app")),
|
|
||||||
).to be_installed
|
|
||||||
|
|
||||||
expect(Cask::Config.global.appdir.join("MyNestedApp.app")).not_to be_quarantined
|
expect(cask).to be_installed
|
||||||
|
|
||||||
|
expect(cask.config.appdir.join("MyNestedApp.app")).not_to be_quarantined
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,25 +4,34 @@ require "test/support/helper/cask/fake_system_command"
|
|||||||
require "test/support/helper/cask/install_helper"
|
require "test/support/helper/cask/install_helper"
|
||||||
require "test/support/helper/cask/never_sudo_system_command"
|
require "test/support/helper/cask/never_sudo_system_command"
|
||||||
|
|
||||||
HOMEBREW_CASK_DIRS = {
|
module Cask
|
||||||
appdir: Pathname.new(TEST_TMPDIR).join("cask-appdir"),
|
class Config
|
||||||
prefpanedir: Pathname.new(TEST_TMPDIR).join("cask-prefpanedir"),
|
remove_const :DEFAULT_DIRS
|
||||||
qlplugindir: Pathname.new(TEST_TMPDIR).join("cask-qlplugindir"),
|
|
||||||
servicedir: Pathname.new(TEST_TMPDIR).join("cask-servicedir"),
|
DEFAULT_DIRS = {
|
||||||
}.freeze
|
appdir: Pathname(TEST_TMPDIR)/"cask-appdir",
|
||||||
|
prefpanedir: Pathname(TEST_TMPDIR)/"cask-prefpanedir",
|
||||||
|
qlplugindir: Pathname(TEST_TMPDIR)/"cask-qlplugindir",
|
||||||
|
dictionarydir: Pathname(TEST_TMPDIR)/"cask-dictionarydir",
|
||||||
|
fontdir: Pathname(TEST_TMPDIR)/"cask-fontdir",
|
||||||
|
colorpickerdir: Pathname(TEST_TMPDIR)/"cask-colorpickerdir",
|
||||||
|
servicedir: Pathname(TEST_TMPDIR)/"cask-servicedir",
|
||||||
|
input_methoddir: Pathname(TEST_TMPDIR)/"cask-input_methoddir",
|
||||||
|
internet_plugindir: Pathname(TEST_TMPDIR)/"cask-internet_plugindir",
|
||||||
|
audio_unit_plugindir: Pathname(TEST_TMPDIR)/"cask-audio_unit_plugindir",
|
||||||
|
vst_plugindir: Pathname(TEST_TMPDIR)/"cask-vst_plugindir",
|
||||||
|
vst3_plugindir: Pathname(TEST_TMPDIR)/"cask-vst3_plugindir",
|
||||||
|
screen_saverdir: Pathname(TEST_TMPDIR)/"cask-screen_saverdir",
|
||||||
|
}.freeze
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
RSpec.shared_context "Homebrew Cask", :needs_macos do
|
RSpec.shared_context "Homebrew Cask", :needs_macos do
|
||||||
before do
|
|
||||||
HOMEBREW_CASK_DIRS.each do |method, path|
|
|
||||||
allow(Cask::Config.global).to receive(method).and_return(path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
around do |example|
|
around do |example|
|
||||||
third_party_tap = Tap.fetch("third-party", "tap")
|
third_party_tap = Tap.fetch("third-party", "tap")
|
||||||
begin
|
|
||||||
HOMEBREW_CASK_DIRS.values.each(&:mkpath)
|
|
||||||
|
|
||||||
|
begin
|
||||||
|
Cask::Config::DEFAULT_DIRS.values.each(&:mkpath)
|
||||||
Cask::Config.global.binarydir.mkpath
|
Cask::Config.global.binarydir.mkpath
|
||||||
|
|
||||||
Tap.default_cask_tap.tap do |tap|
|
Tap.default_cask_tap.tap do |tap|
|
||||||
@ -37,11 +46,12 @@ RSpec.shared_context "Homebrew Cask", :needs_macos do
|
|||||||
|
|
||||||
example.run
|
example.run
|
||||||
ensure
|
ensure
|
||||||
FileUtils.rm_rf HOMEBREW_CASK_DIRS.values
|
FileUtils.rm_rf Cask::Config::DEFAULT_DIRS.values
|
||||||
FileUtils.rm_rf [Cask::Config.global.binarydir, Cask::Caskroom.path, Cask::Cache.path]
|
FileUtils.rm_rf [Cask::Config.global.binarydir, Cask::Caskroom.path, Cask::Cache.path]
|
||||||
Tap.default_cask_tap.path.unlink
|
Tap.default_cask_tap.path.unlink
|
||||||
third_party_tap.path.unlink
|
third_party_tap.path.unlink
|
||||||
FileUtils.rm_rf third_party_tap.path.parent
|
FileUtils.rm_rf third_party_tap.path.parent
|
||||||
|
Cask::Config.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user