aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact.rb64
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb3
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/zap.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/doctor.rb175
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb6
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/list.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl.rb17
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb16
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb6
-rw-r--r--Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb21
-rw-r--r--Library/Homebrew/cask/spec/cask/audit_spec.rb3
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb2
-rw-r--r--Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb8
-rw-r--r--Library/Homebrew/cask/spec/support/file_helper.rb8
-rw-r--r--Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb13
-rw-r--r--Library/Homebrew/cask/spec/support/sha256_helper.rb8
-rw-r--r--Library/Homebrew/cask/test/cask/artifact/suite_test.rb2
-rw-r--r--Library/Homebrew/cask/test/cask/artifact/zap_test.rb4
-rw-r--r--Library/Homebrew/cask/test/cask/installer_test.rb169
-rw-r--r--Library/Homebrew/cask/test/test_helper.rb2
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb1
-rw-r--r--Library/Homebrew/dev-cmd/pull.rb4
-rw-r--r--Library/Homebrew/official_taps.rb1
25 files changed, 219 insertions, 324 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact.rb b/Library/Homebrew/cask/lib/hbc/artifact.rb
index 8b4babdf6..b155a125a 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact.rb
@@ -27,41 +27,39 @@ module Hbc
module Artifact
# NOTE: order is important here, since we want to extract nested containers
# before we handle any other artifacts
- def self.artifacts
- [
- PreflightBlock,
- NestedContainer,
- Installer,
- App,
- Suite,
- Artifact, # generic 'artifact' stanza
- Colorpicker,
- Pkg,
- Prefpane,
- Qlplugin,
- Dictionary,
- Font,
- Service,
- StageOnly,
- Binary,
- InputMethod,
- InternetPlugin,
- AudioUnitPlugin,
- VstPlugin,
- Vst3Plugin,
- ScreenSaver,
- Uninstall,
- PostflightBlock,
- Zap,
- ]
- end
+ TYPES = [
+ PreflightBlock,
+ NestedContainer,
+ Installer,
+ App,
+ Suite,
+ Artifact, # generic 'artifact' stanza
+ Colorpicker,
+ Pkg,
+ Prefpane,
+ Qlplugin,
+ Dictionary,
+ Font,
+ Service,
+ StageOnly,
+ Binary,
+ InputMethod,
+ InternetPlugin,
+ AudioUnitPlugin,
+ VstPlugin,
+ Vst3Plugin,
+ ScreenSaver,
+ Uninstall,
+ PostflightBlock,
+ Zap,
+ ].freeze
- def self.for_cask(cask)
+ def self.for_cask(cask, command: SystemCommand, force: false)
odebug "Determining which artifacts are present in Cask #{cask}"
- artifacts.select do |artifact|
- odebug "Checking for artifact class #{artifact}"
- artifact.me?(cask)
- end
+
+ TYPES
+ .select { |klass| klass.me?(cask) }
+ .map { |klass| klass.new(cask, command: command, force: force) }
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb
index 8b5603064..5a3dc098d 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall.rb
@@ -3,6 +3,9 @@ require "hbc/artifact/uninstall_base"
module Hbc
module Artifact
class Uninstall < UninstallBase
+ def uninstall_phase
+ dispatch_uninstall_directives
+ end
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb
index e18e9c311..ce2b1f51a 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb
@@ -54,10 +54,6 @@ module Hbc
path_strings - undeletable
end
- def uninstall_phase
- dispatch_uninstall_directives
- end
-
def dispatch_uninstall_directives(expand_tilde: true)
directives_set = @cask.artifacts[stanza]
ohai "Running #{stanza} process for #{@cask}; your password may be necessary"
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb
index b31e2ef11..7793e5772 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb
@@ -3,7 +3,7 @@ require "hbc/artifact/uninstall_base"
module Hbc
module Artifact
class Zap < UninstallBase
- def uninstall_phase
+ def zap_phase
dispatch_uninstall_directives(expand_tilde: true)
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb
index 2b2211877..73ab121d2 100644
--- a/Library/Homebrew/cask/lib/hbc/cli.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli.rb
@@ -152,7 +152,7 @@ module Hbc
Hbc.default_tap.install unless Hbc.default_tap.installed?
Hbc.init if should_init?(command)
run_command(command, *rest)
- rescue CaskError, CaskSha256MismatchError => e
+ rescue CaskError, CaskSha256MismatchError, ArgumentError => e
msg = e.message
msg << e.backtrace.join("\n") if Hbc.debug
onoe msg
diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
index 84d8e1ebc..6b2f4caab 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
@@ -2,116 +2,39 @@ module Hbc
class CLI
class Doctor < Base
def self.run
- ohai "macOS Release:", render_with_none_as_error(MacOS.full_version)
- ohai "Hardware Architecture:", render_with_none_as_error("#{Hardware::CPU.type}-#{Hardware::CPU.bits}")
- ohai "Ruby Version:", render_with_none_as_error("#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}")
- ohai "Ruby Path:", render_with_none_as_error(RbConfig.ruby)
- # TODO: consider removing most Homebrew constants from doctor output
- ohai "Homebrew Version:", render_with_none_as_error(homebrew_version)
- ohai "Homebrew Executable Path:", render_with_none_as_error(HOMEBREW_BREW_FILE)
- ohai "Homebrew Cellar Path:", render_with_none_as_error(homebrew_cellar)
- ohai "Homebrew Repository Path:", render_with_none_as_error(HOMEBREW_REPOSITORY)
- ohai "Homebrew Origin:", render_with_none_as_error(homebrew_origin)
- ohai "Homebrew-Cask Version:", render_with_none_as_error(Hbc.full_version)
- ohai "Homebrew-Cask Install Location:", render_install_location
- ohai "Homebrew-Cask Staging Location:", render_staging_location(Hbc.caskroom)
- ohai "Homebrew-Cask Cached Downloads:", render_cached_downloads
- ohai "Homebrew-Cask Default Tap Path:", render_tap_paths(Hbc.default_tap.path)
- ohai "Homebrew-Cask Alternate Cask Taps:", render_tap_paths(alt_taps)
- ohai "Homebrew-Cask Default Tap Cask Count:", render_with_none_as_error(default_cask_count)
- ohai "Contents of $LOAD_PATH:", render_load_path($LOAD_PATH)
- ohai "Contents of $RUBYLIB Environment Variable:", render_env_var("RUBYLIB")
- ohai "Contents of $RUBYOPT Environment Variable:", render_env_var("RUBYOPT")
- ohai "Contents of $RUBYPATH Environment Variable:", render_env_var("RUBYPATH")
- ohai "Contents of $RBENV_VERSION Environment Variable:", render_env_var("RBENV_VERSION")
- ohai "Contents of $CHRUBY_VERSION Environment Variable:", render_env_var("CHRUBY_VERSION")
- ohai "Contents of $GEM_HOME Environment Variable:", render_env_var("GEM_HOME")
- ohai "Contents of $GEM_PATH Environment Variable:", render_env_var("GEM_PATH")
- ohai "Contents of $BUNDLE_PATH Environment Variable:", render_env_var("BUNDLE_PATH")
- ohai "Contents of $PATH Environment Variable:", render_env_var("PATH")
- ohai "Contents of $SHELL Environment Variable:", render_env_var("SHELL")
- ohai "Contents of Locale Environment Variables:", render_with_none(locale_variables)
- end
-
- def self.alt_taps
- Tap.select { |t| t.cask_dir && t != Hbc.default_tap }
- .map(&:path)
- end
-
- def self.default_cask_count
- Hbc.default_tap.cask_files.count
- rescue StandardError
- "0 #{error_string "Error reading #{Hbc.default_tap.path}"}"
- end
-
- def self.homebrew_origin
- homebrew_origin = notfound_string
- begin
- Dir.chdir(HOMEBREW_REPOSITORY) do
- homebrew_origin = SystemCommand.run("/usr/bin/git",
- args: %w[config --get remote.origin.url],
- print_stderr: false).stdout.strip
- end
- if homebrew_origin !~ /\S/
- homebrew_origin = "#{none_string} #{error_string}"
- elsif homebrew_origin !~ %r{(mxcl|Homebrew)/(home)?brew(\.git)?\Z}
- homebrew_origin.concat " #{error_string "warning: nonstandard origin"}"
- end
- rescue StandardError
- homebrew_origin = error_string "Not Found - Error running git"
- end
- homebrew_origin
- end
-
- def self.homebrew_cellar
- homebrew_constants("cellar")
- end
-
- def self.homebrew_version
- homebrew_constants("version")
- end
-
- def self.homebrew_taps
- Tap::TAP_DIRECTORY
- end
-
- def self.homebrew_constants(name)
- @homebrew_constants ||= {}
- return @homebrew_constants[name] if @homebrew_constants.key?(name)
- @homebrew_constants[name] = notfound_string
- begin
- @homebrew_constants[name] = SystemCommand.run!(HOMEBREW_BREW_FILE,
- args: ["--#{name}"],
- print_stderr: false)
- .stdout
- .strip
- if @homebrew_constants[name] !~ /\S/
- @homebrew_constants[name] = "#{none_string} #{error_string}"
- end
- path = Pathname.new(@homebrew_constants[name])
- @homebrew_constants[name] = path if path.exist?
- rescue StandardError
- @homebrew_constants[name] = error_string "Not Found - Error running brew"
- end
- @homebrew_constants[name]
+ ohai "Homebrew-Cask Version", Hbc.full_version
+ ohai "Homebrew-Cask Install Location", render_install_location
+ ohai "Homebrew-Cask Staging Location", render_staging_location(Hbc.caskroom)
+ ohai "Homebrew-Cask Cached Downloads", render_cached_downloads
+ ohai "Homebrew-Cask Taps:"
+ puts render_taps(Hbc.default_tap, *alt_taps)
+ ohai "Contents of $LOAD_PATH", render_load_path($LOAD_PATH)
+ ohai "Environment Variables"
+
+ environment_variables = [
+ "RUBYLIB",
+ "RUBYOPT",
+ "RUBYPATH",
+ "RBENV_VERSION",
+ "CHRUBY_VERSION",
+ "GEM_HOME",
+ "GEM_PATH",
+ "BUNDLE_PATH",
+ "PATH",
+ "SHELL",
+ ]
+
+ (locale_variables + environment_variables).sort.each(&method(:render_env_var))
end
def self.locale_variables
- ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).collect { |v| %Q(#{v}="#{ENV[v]}") }.sort.join("\n")
+ ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).sort
end
def self.none_string
"<NONE>"
end
- def self.legacy_tap_pattern
- /phinze/
- end
-
- def self.notfound_string
- Formatter.error("Not Found - Unknown Error")
- end
-
def self.error_string(string = "Error")
Formatter.error("(#{string})")
end
@@ -121,37 +44,42 @@ module Hbc
none_string
end
- def self.render_with_none_as_error(string)
- return string if !string.nil? && string.respond_to?(:to_s) && !string.to_s.empty?
- "#{none_string} #{error_string}"
+ def self.alt_taps
+ Tap.select { |t| t.cask_dir && t != Hbc.default_tap }
end
- def self.render_tap_paths(paths)
- paths = [paths] unless paths.respond_to?(:each)
- paths.collect do |dir|
- if dir.nil? || dir.to_s.empty?
+ def self.cask_count_for_tap(tap)
+ count = tap.cask_files.count
+ "#{count} #{count == 1 ? "cask" : "casks"}"
+ rescue StandardError
+ "0 #{error_string "error reading #{tap.path}"}"
+ end
+
+ def self.render_taps(*taps)
+ taps.collect do |tap|
+ if tap.path.nil? || tap.path.to_s.empty?
none_string
- elsif dir.to_s.match(legacy_tap_pattern)
- dir.to_s.concat(" #{error_string "Warning: legacy tap path"}")
else
- dir.to_s
+ "#{tap.path} (#{cask_count_for_tap(tap)})"
end
end
end
def self.render_env_var(var)
- if ENV.key?(var)
- %Q(#{var}="#{ENV[var]}")
- else
- none_string
- end
+ return unless ENV.key?(var)
+ var = %Q(#{var}="#{ENV[var]}")
+ puts user_tilde(var)
+ end
+
+ def self.user_tilde(path)
+ path.gsub(ENV["HOME"], "~")
end
# This could be done by calling into Homebrew, but the situation
# where "doctor" is needed is precisely the situation where such
# things are less dependable.
def self.render_install_location
- locations = Dir.glob(Pathname.new(homebrew_cellar).join("brew-cask", "*")).reverse
+ locations = Dir.glob(HOMEBREW_CELLAR.join("brew-cask", "*")).reverse
if locations.empty?
none_string
else
@@ -162,7 +90,7 @@ module Hbc
end
def self.render_staging_location(path)
- path = Pathname.new(path)
+ path = Pathname.new(user_tilde(path.to_s))
if !path.exist?
"#{path} #{error_string "error: path does not exist"}}"
elsif !path.writable?
@@ -173,19 +101,18 @@ module Hbc
end
def self.render_load_path(paths)
+ paths.map(&method(:user_tilde))
return "#{none_string} #{error_string}" if [*paths].empty?
paths
end
def self.render_cached_downloads
cleanup = CLI::Cleanup.default
- files = cleanup.cache_files
- count = files.count
+ count = cleanup.cache_files.count
size = cleanup.disk_cleanup_size
- size_msg = "#{number_readable(count)} files, #{disk_usage_readable(size)}"
- warn_msg = error_string('warning: run "brew cask cleanup"')
- size_msg << " #{warn_msg}" if count > 0
- [Hbc.cache, size_msg]
+ msg = user_tilde(Hbc.cache.to_s)
+ msg << " (#{number_readable(count)} files, #{disk_usage_readable(size)})" unless count.zero?
+ msg
end
def self.help
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
index 105e946d7..c54db8795 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
@@ -44,13 +44,15 @@ module Hbc
:stage_only,
:nested_container,
:uninstall,
- :postflight,
- :uninstall_postflight,
:preflight,
+ :postflight,
+ :uninstall_preflight,
:uninstall_postflight,
]
def self.run(*args)
+ raise ArgumentError, "No stanza given." if args.empty?
+
table = args.include? "--table"
quiet = args.include? "--quiet"
format = :to_yaml if args.include? "--yaml"
diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb
index 4094b3d38..e100fbd83 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/list.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb
@@ -55,7 +55,7 @@ module Hbc
def self.list_artifacts(cask)
Artifact.for_cask(cask).each do |artifact|
- summary = artifact.new(cask).summary
+ summary = artifact.summary
ohai summary[:english_description], summary[:contents] unless summary.empty?
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb
index c62873665..4707ae76a 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl.rb
@@ -270,14 +270,17 @@ module Hbc
ORDINARY_ARTIFACT_TYPES.each do |type|
define_method(type) do |*args|
- if type == :stage_only && args != [true]
- raise CaskInvalidError.new(token, "'stage_only' takes a single argument: true")
- end
- artifacts[type] << args
- if artifacts.key?(:stage_only) && artifacts.keys.count > 1 &&
- !(artifacts.keys & ACTIVATABLE_ARTIFACT_TYPES).empty?
- raise CaskInvalidError.new(token, "'stage_only' must be the only activatable artifact")
+ if type == :stage_only
+ if args != [true]
+ raise CaskInvalidError.new(token, "'stage_only' takes a single argument: true")
+ end
+
+ unless (artifacts.keys & ACTIVATABLE_ARTIFACT_TYPES).empty?
+ raise CaskInvalidError.new(token, "'stage_only' must be the only activatable artifact")
+ end
end
+
+ artifacts[type].add(args)
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 28f67e5fd..cafc9d8b9 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -133,16 +133,14 @@ module Hbc
def install_artifacts
already_installed_artifacts = []
- options = { command: @command, force: force }
odebug "Installing artifacts"
- artifacts = Artifact.for_cask(@cask)
+ artifacts = Artifact.for_cask(@cask, command: @command, force: force)
odebug "#{artifacts.length} artifact/s defined", artifacts
artifacts.each do |artifact|
- artifact = artifact.new(@cask, options)
next unless artifact.respond_to?(:install_phase)
- odebug "Installing artifact of class #{artifact}"
+ odebug "Installing artifact of class #{artifact.class}"
artifact.install_phase
already_installed_artifacts.unshift(artifact)
end
@@ -150,7 +148,7 @@ module Hbc
begin
already_installed_artifacts.each do |artifact|
next unless artifact.respond_to?(:uninstall_phase)
- odebug "Reverting installation of artifact of class #{artifact}"
+ odebug "Reverting installation of artifact of class #{artifact.class}"
artifact.uninstall_phase
end
ensure
@@ -319,13 +317,11 @@ module Hbc
def uninstall_artifacts
odebug "Un-installing artifacts"
- artifacts = Artifact.for_cask(@cask)
+ artifacts = Artifact.for_cask(@cask, command: @command, force: force)
odebug "#{artifacts.length} artifact/s defined", artifacts
artifacts.each do |artifact|
- options = { command: @command, force: force }
- artifact = artifact.new(@cask, options)
next unless artifact.respond_to?(:uninstall_phase)
- odebug "Un-installing artifact of class #{artifact}"
+ odebug "Un-installing artifact of class #{artifact.class}"
artifact.uninstall_phase
end
end
@@ -335,7 +331,7 @@ module Hbc
uninstall_artifacts
if Artifact::Zap.me?(@cask)
ohai "Dispatching zap stanza"
- Artifact::Zap.new(@cask, command: @command).uninstall_phase
+ Artifact::Zap.new(@cask, command: @command).zap_phase
else
opoo "No zap stanza present for Cask '#{@cask}'"
end
diff --git a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb
index 95ac2b5f5..c27dcc8f0 100644
--- a/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/artifact/binary_spec.rb
@@ -20,7 +20,8 @@ describe Hbc::Artifact::Binary do
shutup do
Hbc::Artifact::Binary.new(cask).install_phase
end
- expect(FileHelper.valid_alias?(expected_path)).to be true
+ expect(expected_path).to be_a_symlink
+ expect(expected_path.readlink).to exist
end
it "avoids clobbering an existing binary by linking over it" do
@@ -82,7 +83,8 @@ describe Hbc::Artifact::Binary do
Hbc::Artifact::Binary.new(cask).install_phase
end
- expect(FileHelper.valid_alias?(expected_path)).to be true
+ expect(expected_path).to be_a_symlink
+ expect(expected_path.readlink).to exist
end
end
end
diff --git a/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb b/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb
new file mode 100644
index 000000000..3150b50be
--- /dev/null
+++ b/Library/Homebrew/cask/spec/cask/artifact/uninstall_no_zap_spec.rb
@@ -0,0 +1,21 @@
+require "spec_helper"
+
+describe Hbc::Artifact::Zap do
+ let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installable.rb") }
+
+ let(:zap_artifact) {
+ Hbc::Artifact::Zap.new(cask)
+ }
+
+ before do
+ shutup do
+ InstallHelper.install_without_artifacts(cask)
+ end
+ end
+
+ describe "#uninstall_phase" do
+ subject { zap_artifact }
+
+ it { is_expected.not_to respond_to(:uninstall_phase) }
+ end
+end
diff --git a/Library/Homebrew/cask/spec/cask/audit_spec.rb b/Library/Homebrew/cask/spec/cask/audit_spec.rb
index 193b58fd6..9eb9f0136 100644
--- a/Library/Homebrew/cask/spec/cask/audit_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/audit_spec.rb
@@ -1,6 +1,5 @@
describe Hbc::Audit do
include AuditMatchers
- include Sha256Helper
let(:cask) { instance_double(Hbc::Cask) }
let(:download) { false }
@@ -178,7 +177,7 @@ describe Hbc::Audit do
end
context "when appcast checkpoint is out of date" do
- let(:actual_checkpoint) { random_sha256 }
+ let(:actual_checkpoint) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" }
it { is_expected.to warn_with(mismatch_msg) }
it { should_not warn_with(curl_error_msg) }
end
diff --git a/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb b/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb
index 38f8b50ac..ff1cf5706 100644
--- a/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/doctor_spec.rb
@@ -4,7 +4,7 @@ describe Hbc::CLI::Doctor do
it "displays some nice info about the environment" do
expect {
Hbc::CLI::Doctor.run
- }.to output(/\A==> macOS Release:/).to_stdout
+ }.to output(/\A==> Homebrew-Cask Version/).to_stdout
end
it "raises an exception when arguments are given" do
diff --git a/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb b/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb
index a379dafb9..d803c566d 100644
--- a/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/verify/checksum_spec.rb
@@ -1,6 +1,4 @@
describe Hbc::Verify::Checksum do
- include Sha256Helper
-
let(:cask) { double("cask") }
let(:downloaded_path) { double("downloaded_path") }
let(:verification) { described_class.new(cask, downloaded_path) }
@@ -35,7 +33,7 @@ describe Hbc::Verify::Checksum do
end
context "sha256 is a valid shasum" do
- let(:sha256) { random_sha256 }
+ let(:sha256) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" }
it { is_expected.to be true }
end
@@ -44,7 +42,7 @@ describe Hbc::Verify::Checksum do
describe "#verify" do
subject { verification.verify }
- let(:computed) { random_sha256 }
+ let(:computed) { "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" }
before do
allow(verification).to receive(:computed).and_return(computed)
@@ -67,7 +65,7 @@ describe Hbc::Verify::Checksum do
end
context "sha256 does not match computed" do
- let(:sha256) { random_sha256 }
+ let(:sha256) { "d3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33fd3adb33f" }
it "raises an error" do
expect { subject }.to raise_error(Hbc::CaskSha256MismatchError)
diff --git a/Library/Homebrew/cask/spec/support/file_helper.rb b/Library/Homebrew/cask/spec/support/file_helper.rb
deleted file mode 100644
index abe7b2618..000000000
--- a/Library/Homebrew/cask/spec/support/file_helper.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-module FileHelper
- module_function
-
- def valid_alias?(candidate)
- return false unless candidate.symlink?
- candidate.readlink.exist?
- end
-end
diff --git a/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb b/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb
deleted file mode 100644
index b5c84869b..000000000
--- a/Library/Homebrew/cask/spec/support/kernel_at_exit_hacks.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module Kernel
- alias real_at_exit at_exit
-
- def at_exit(&block)
- real_at_exit(&block) unless ENV["DISABLE_AT_EXIT"]
- end
-
- def with_disabled_at_exit
- ENV["DISABLE_AT_EXIT"] = "1"
- yield
- ENV.delete("DISABLE_AT_EXIT")
- end
-end
diff --git a/Library/Homebrew/cask/spec/support/sha256_helper.rb b/Library/Homebrew/cask/spec/support/sha256_helper.rb
deleted file mode 100644
index 14f2a2519..000000000
--- a/Library/Homebrew/cask/spec/support/sha256_helper.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require"digest"
-
-module Sha256Helper
- def random_sha256
- seed = "--#{rand(10_000)}--#{Time.now}--"
- Digest::SHA2.hexdigest(seed)
- end
-end
diff --git a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb
index 0584dcbeb..6259baa4b 100644
--- a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb
+++ b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb
@@ -20,7 +20,7 @@ describe Hbc::Artifact::Suite do
end
target_path.must_be :directory?
- TestHelper.valid_alias?(target_path).must_equal false
+ TestHelper.valid_symlink?(target_path).must_equal false
source_path.wont_be :exist?
end
diff --git a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb
index ea546728b..37a65f863 100644
--- a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb
+++ b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb
@@ -14,10 +14,10 @@ describe Hbc::Artifact::Zap do
end
end
- describe "uninstall_phase" do
+ describe "#zap_phase" do
subject {
shutup do
- zap_artifact.uninstall_phase
+ zap_artifact.zap_phase
end
}
diff --git a/Library/Homebrew/cask/test/cask/installer_test.rb b/Library/Homebrew/cask/test/cask/installer_test.rb
index b26c28847..17629dce2 100644
--- a/Library/Homebrew/cask/test/cask/installer_test.rb
+++ b/Library/Homebrew/cask/test/cask/installer_test.rb
@@ -13,10 +13,8 @@ describe Hbc::Installer do
Hbc::Installer.new(caffeine).install
end
- dest_path = Hbc.caskroom.join("local-caffeine", caffeine.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("Caffeine.app")
- application.must_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).must_be :directory?
+ expect(Hbc.appdir.join("Caffeine.app")).must_be :directory?
end
it "works with dmg-based Casks" do
@@ -26,10 +24,8 @@ describe Hbc::Installer do
Hbc::Installer.new(asset).install
end
- dest_path = Hbc.caskroom.join("container-dmg", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container")
- file.must_be :file?
+ expect(Hbc.caskroom.join("container-dmg", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container")).must_be :file?
end
it "works with tar-gz-based Casks" do
@@ -39,10 +35,8 @@ describe Hbc::Installer do
Hbc::Installer.new(asset).install
end
- dest_path = Hbc.caskroom.join("container-tar-gz", asset.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("container")
- application.must_be :file?
+ expect(Hbc.caskroom.join("container-tar-gz", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container")).must_be :file?
end
it "works with cab-based Casks" do
@@ -55,10 +49,8 @@ describe Hbc::Installer do
end
end
- dest_path = Hbc.caskroom.join("container-cab", asset.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("container")
- application.must_be :file?
+ expect(Hbc.caskroom.join("container-cab", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container")).must_be :file?
end
it "works with Adobe AIR-based Casks" do
@@ -69,10 +61,8 @@ describe Hbc::Installer do
Hbc::Installer.new(asset).install
end
- dest_path = Hbc.caskroom.join("container-air", asset.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("container.app")
- application.must_be :directory?
+ expect(Hbc.caskroom.join("container-air", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container.app")).must_be :directory?
end
it "works with 7z-based Casks" do
@@ -85,10 +75,8 @@ describe Hbc::Installer do
end
end
- dest_path = Hbc.caskroom.join("container-7z", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container")
- file.must_be :file?
+ expect(Hbc.caskroom.join("container-7z", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container")).must_be :file?
end
it "works with xar-based Casks" do
@@ -98,10 +86,8 @@ describe Hbc::Installer do
Hbc::Installer.new(asset).install
end
- dest_path = Hbc.caskroom.join("container-xar", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container")
- file.must_be :file?
+ expect(Hbc.caskroom.join("container-xar", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container")).must_be :file?
end
it "works with Stuffit-based Casks" do
@@ -114,10 +100,8 @@ describe Hbc::Installer do
end
end
- dest_path = Hbc.caskroom.join("container-sit", asset.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("container")
- application.must_be :file?
+ expect(Hbc.caskroom.join("container-sit", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container")).must_be :file?
end
it "works with RAR-based Casks" do
@@ -130,10 +114,8 @@ describe Hbc::Installer do
end
end
- dest_path = Hbc.caskroom.join("container-rar", asset.version)
- dest_path.must_be :directory?
- application = Hbc.appdir.join("container")
- application.must_be :file?
+ expect(Hbc.caskroom.join("container-rar", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container")).must_be :file?
end
it "works with pure bzip2-based Casks" do
@@ -143,10 +125,8 @@ describe Hbc::Installer do
Hbc::Installer.new(asset).install
end
- dest_path = Hbc.caskroom.join("container-bzip2", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container-bzip2--#{asset.version}")
- file.must_be :file?
+ expect(Hbc.caskroom.join("container-bzip2", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container-bzip2--#{asset.version}")).must_be :file?
end
it "works with pure gzip-based Casks" do
@@ -156,10 +136,8 @@ describe Hbc::Installer do
Hbc::Installer.new(asset).install
end
- dest_path = Hbc.caskroom.join("container-gzip", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container")
- file.must_be :file?
+ expect(Hbc.caskroom.join("container-gzip", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container")).must_be :file?
end
it "works with pure xz-based Casks" do
@@ -172,10 +150,8 @@ describe Hbc::Installer do
end
end
- dest_path = Hbc.caskroom.join("container-xz", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container-xz--#{asset.version}")
- file.must_be :file?
+ expect(Hbc.caskroom.join("container-xz", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container-xz--#{asset.version}")).must_be :file?
end
it "works with lzma-based Casks" do
@@ -188,15 +164,13 @@ describe Hbc::Installer do
end
end
- dest_path = Hbc.caskroom.join("container-lzma", asset.version)
- dest_path.must_be :directory?
- file = Hbc.appdir.join("container-lzma--#{asset.version}")
- file.must_be :file?
+ expect(Hbc.caskroom.join("container-lzma", asset.version)).must_be :directory?
+ expect(Hbc.appdir.join("container-lzma--#{asset.version}")).must_be :file?
end
it "blows up on a bad checksum" do
bad_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/bad-checksum.rb")
- lambda {
+ expect {
shutup do
Hbc::Installer.new(bad_checksum).install
end
@@ -205,7 +179,7 @@ describe Hbc::Installer do
it "blows up on a missing checksum" do
missing_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/missing-checksum.rb")
- lambda {
+ expect {
shutup do
Hbc::Installer.new(missing_checksum).install
end
@@ -219,12 +193,12 @@ describe Hbc::Installer do
Hbc::Installer.new(no_checksum).install
end
- no_checksum.must_be :installed?
+ expect(no_checksum).must_be :installed?
end
it "fails to install if sha256 :no_check is used with --require-sha" do
no_checksum = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/no-checksum.rb")
- lambda {
+ expect {
Hbc::Installer.new(no_checksum, require_sha: true).install
}.must_raise(Hbc::CaskNoShasumError)
end
@@ -236,23 +210,27 @@ describe Hbc::Installer do
Hbc::Installer.new(no_checksum, require_sha: true, force: true).install
end
- no_checksum.must_be :installed?
+ expect(no_checksum).must_be :installed?
end
it "prints caveats if they're present" do
with_caveats = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-caveats.rb")
- lambda {
+
+ expect {
Hbc::Installer.new(with_caveats).install
}.must_output(/Here are some things you might want to know/)
- with_caveats.must_be :installed?
+
+ expect(with_caveats).must_be :installed?
end
it "prints installer :manual instructions when present" do
with_installer_manual = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-installer-manual.rb")
- lambda {
+
+ expect {
Hbc::Installer.new(with_installer_manual).install
}.must_output(/To complete the installation of Cask with-installer-manual, you must also\nrun the installer at\n\n '#{with_installer_manual.staged_path.join('Caffeine.app')}'/)
- with_installer_manual.must_be :installed?
+
+ expect(with_installer_manual).must_be :installed?
end
it "does not extract __MACOSX directories from zips" do
@@ -262,54 +240,60 @@ describe Hbc::Installer do
Hbc::Installer.new(with_macosx_dir).install
end
- with_macosx_dir.staged_path.join("__MACOSX").wont_be :directory?
+ expect(with_macosx_dir.staged_path.join("__MACOSX")).wont_be :directory?
end
it "installer method raises an exception when already-installed Casks which auto-update are attempted" do
- auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb")
- auto_updates.installed?.must_equal false
- installer = Hbc::Installer.new(auto_updates)
+ with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb")
+
+ expect(with_auto_updates).wont_be :installed?
+
+ installer = Hbc::Installer.new(with_auto_updates)
shutup do
installer.install
end
- lambda {
+ expect {
installer.install
}.must_raise(Hbc::CaskAlreadyInstalledAutoUpdatesError)
end
it "allows already-installed Casks which auto-update to be installed if force is provided" do
- auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb")
- auto_updates.installed?.must_equal false
+ with_auto_updates = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/auto-updates.rb")
+
+ expect(with_auto_updates).wont_be :installed?
shutup do
- Hbc::Installer.new(auto_updates).install
+ Hbc::Installer.new(with_auto_updates).install
end
shutup do
- Hbc::Installer.new(auto_updates, force: true).install
+ Hbc::Installer.new(with_auto_updates, force: true).install
end # wont_raise
end
# unlike the CLI, the internal interface throws exception on double-install
it "installer method raises an exception when already-installed Casks are attempted" do
transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
- transmission.installed?.must_equal false
+
+ expect(transmission).wont_be :installed?
+
installer = Hbc::Installer.new(transmission)
shutup do
installer.install
end
- lambda {
+ expect {
installer.install
}.must_raise(Hbc::CaskAlreadyInstalledError)
end
it "allows already-installed Casks to be installed if force is provided" do
transmission = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/local-transmission.rb")
- transmission.installed?.must_equal false
+
+ expect(transmission).wont_be :installed?
shutup do
Hbc::Installer.new(transmission).install
@@ -327,9 +311,7 @@ describe Hbc::Installer do
Hbc::Installer.new(naked_pkg).install
end
- dest_path = Hbc.caskroom.join("container-pkg", naked_pkg.version)
- pkg = dest_path.join("container.pkg")
- pkg.must_be :file?
+ expect(Hbc.caskroom.join("container-pkg", naked_pkg.version, "container.pkg")).must_be :file?
end
it "works properly with an overridden container :type" do
@@ -339,9 +321,7 @@ describe Hbc::Installer do
Hbc::Installer.new(naked_executable).install
end
- dest_path = Hbc.caskroom.join("naked-executable", naked_executable.version)
- executable = dest_path.join("naked_executable")
- executable.must_be :file?
+ expect(Hbc.caskroom.join("naked-executable", naked_executable.version, "naked_executable")).must_be :file?
end
it "works fine with a nested container" do
@@ -351,8 +331,7 @@ describe Hbc::Installer do
Hbc::Installer.new(nested_app).install
end
- dest_path = Hbc.appdir.join("MyNestedApp.app")
- dest_path.must_be :directory?
+ expect(Hbc.appdir.join("MyNestedApp.app")).must_be :directory?
end
it "generates and finds a timestamped metadata directory for an installed Cask" do
@@ -363,8 +342,8 @@ describe Hbc::Installer do
end
m_path = caffeine.metadata_path(:now, true)
- caffeine.metadata_path(:now, false).must_equal(m_path)
- caffeine.metadata_path(:latest).must_equal(m_path)
+ expect(caffeine.metadata_path(:now, false)).must_equal(m_path)
+ expect(caffeine.metadata_path(:latest)).must_equal(m_path)
end
it "generates and finds a metadata subdirectory for an installed Cask" do
@@ -376,8 +355,8 @@ describe Hbc::Installer do
subdir_name = "Casks"
m_subdir = caffeine.metadata_subdir(subdir_name, :now, true)
- caffeine.metadata_subdir(subdir_name, :now, false).must_equal(m_subdir)
- caffeine.metadata_subdir(subdir_name, :latest).must_equal(m_subdir)
+ expect(caffeine.metadata_subdir(subdir_name, :now, false)).must_equal(m_subdir)
+ expect(caffeine.metadata_subdir(subdir_name, :latest)).must_equal(m_subdir)
end
end
@@ -391,9 +370,9 @@ describe Hbc::Installer do
installer.uninstall
end
- Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app").wont_be :directory?
- Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory?
- Hbc.caskroom.join("local-caffeine").wont_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version, "Caffeine.app")).wont_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).wont_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine")).wont_be :directory?
end
it "uninstalls all versions if force is set" do
@@ -404,19 +383,19 @@ describe Hbc::Installer do
Hbc::Installer.new(caffeine).install
end
- Hbc.caskroom.join("local-caffeine", caffeine.version).must_be :directory?
- Hbc.caskroom.join("local-caffeine", mutated_version).wont_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).must_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine", mutated_version)).wont_be :directory?
FileUtils.mv(Hbc.caskroom.join("local-caffeine", caffeine.version), Hbc.caskroom.join("local-caffeine", mutated_version))
- Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory?
- Hbc.caskroom.join("local-caffeine", mutated_version).must_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).wont_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine", mutated_version)).must_be :directory?
shutup do
Hbc::Installer.new(caffeine, force: true).uninstall
end
- Hbc.caskroom.join("local-caffeine", caffeine.version).wont_be :directory?
- Hbc.caskroom.join("local-caffeine", mutated_version).wont_be :directory?
- Hbc.caskroom.join("local-caffeine").wont_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine", caffeine.version)).wont_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine", mutated_version)).wont_be :directory?
+ expect(Hbc.caskroom.join("local-caffeine")).wont_be :directory?
end
end
end
diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb
index 71ce5752e..f600a1c5c 100644
--- a/Library/Homebrew/cask/test/test_helper.rb
+++ b/Library/Homebrew/cask/test/test_helper.rb
@@ -58,7 +58,7 @@ class TestHelper
"file://" + local_binary_path(name)
end
- def self.valid_alias?(candidate)
+ def self.valid_symlink?(candidate)
return false unless candidate.symlink?
candidate.readlink.exist?
end
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index b5dc4ecb1..7a5d38afe 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1343,6 +1343,7 @@ class ResourceAuditor
%r{^http://(?:[^/]*\.)?bintray\.com/},
%r{^http://tools\.ietf\.org/},
%r{^http://launchpad\.net/},
+ %r{^http://github\.com/},
%r{^http://bitbucket\.org/},
%r{^http://anonscm\.debian\.org/},
%r{^http://cpan\.metacpan\.org/},
diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb
index 8771788e4..c2342d39c 100644
--- a/Library/Homebrew/dev-cmd/pull.rb
+++ b/Library/Homebrew/dev-cmd/pull.rb
@@ -376,7 +376,7 @@ module Homebrew
subject_strs << "remove stable"
formula_name_str += ":" # just for cosmetics
else
- subject_strs << formula.version.to_s
+ subject_strs << new[:stable]
end
end
if old[:devel] != new[:devel]
@@ -387,7 +387,7 @@ module Homebrew
formula_name_str += ":" # just for cosmetics
end
else
- subject_strs << "#{formula.devel.version} (devel)"
+ subject_strs << "#{new[:devel]} (devel)"
end
end
subject = subject_strs.empty? ? nil : "#{formula_name_str} #{subject_strs.join(", ")}"
diff --git a/Library/Homebrew/official_taps.rb b/Library/Homebrew/official_taps.rb
index 024dd2a20..35295c1e8 100644
--- a/Library/Homebrew/official_taps.rb
+++ b/Library/Homebrew/official_taps.rb
@@ -3,7 +3,6 @@ OFFICIAL_TAPS = %w[
dupes
emacs
fuse
- games
nginx
php
science