aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/cask.rb8
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/list.rb3
-rw-r--r--Library/Homebrew/cmd/list.rb10
-rw-r--r--Library/Homebrew/cmd/style.rb4
-rw-r--r--Library/Homebrew/extend/os/mac/extend/ENV/super.rb9
-rw-r--r--Library/Homebrew/os/mac/linkage_checker.rb19
-rw-r--r--Library/Homebrew/test/cask/cask_spec.rb34
-rw-r--r--Library/Homebrew/test/cask/cli/list_spec.rb20
-rw-r--r--Library/Homebrew/test/support/fixtures/third-party/Casks/third-party-cask.rb9
-rw-r--r--Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb8
-rw-r--r--Library/Homebrew/test/utils_spec.rb29
-rw-r--r--Library/Homebrew/utils.rb12
13 files changed, 152 insertions, 17 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb b/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb
index 6670d4249..4e8edbc11 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb
@@ -43,6 +43,10 @@ module Hbc
return if (block = directives[dsl_key]).nil?
class_for_dsl_key(dsl_key).new(cask).instance_eval(&block)
end
+
+ def summarize
+ directives.keys.map(&:to_s).join(", ")
+ end
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb
index 27f8ae791..72a23066f 100644
--- a/Library/Homebrew/cask/lib/hbc/cask.rb
+++ b/Library/Homebrew/cask/lib/hbc/cask.rb
@@ -41,6 +41,14 @@ module Hbc
.reverse
end
+ def full_name
+ if @tap.nil? || @tap == Hbc.default_tap
+ token
+ else
+ "#{@tap}/#{token}"
+ end
+ end
+
def installed?
!versions.empty?
end
diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb
index faa1160a1..32415af8a 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/list.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb
@@ -3,6 +3,7 @@ module Hbc
class List < AbstractCommand
option "-1", :one, false
option "--versions", :versions, false
+ option "--full-name", :full_name, false
option "-l", (lambda do |*|
one = true # rubocop:disable Lint/UselessAssignment
@@ -42,6 +43,8 @@ module Hbc
puts installed_casks.map(&:to_s)
elsif versions?
puts installed_casks.map(&self.class.method(:format_versioned))
+ elsif full_name?
+ puts installed_casks.map(&:full_name).sort &tap_and_name_comparison
elsif !installed_casks.empty?
puts Formatter.columns(installed_casks.map(&:to_s))
end
diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb
index f5c4e68ac..436fc1f97 100644
--- a/Library/Homebrew/cmd/list.rb
+++ b/Library/Homebrew/cmd/list.rb
@@ -39,15 +39,7 @@ module Homebrew
filtered_list
elsif ARGV.named.empty?
if ARGV.include? "--full-name"
- full_names = Formula.installed.map(&:full_name).sort do |a, b|
- if a.include?("/") && !b.include?("/")
- 1
- elsif !a.include?("/") && b.include?("/")
- -1
- else
- a <=> b
- end
- end
+ full_names = Formula.installed.map(&:full_name).sort &tap_and_name_comparison
return if full_names.empty?
puts Formatter.columns(full_names)
else
diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb
index b0f46fadc..e816db5dc 100644
--- a/Library/Homebrew/cmd/style.rb
+++ b/Library/Homebrew/cmd/style.rb
@@ -119,10 +119,10 @@ module Homebrew
when :print
args << "--display-cop-names" if ARGV.include? "--display-cop-names"
args << "--format" << "simple" if files
- system(cache_env, "rubocop", *args)
+ system(cache_env, "rubocop", "_#{HOMEBREW_RUBOCOP_VERSION}_", *args)
!$CHILD_STATUS.success?
when :json
- json, _, status = Open3.capture3(cache_env, "rubocop", "--format", "json", *args)
+ json, _, status = Open3.capture3(cache_env, "rubocop", "_#{HOMEBREW_RUBOCOP_VERSION}_", "--format", "json", *args)
# exit status of 1 just means violations were found; other numbers mean
# execution errors.
# exitstatus can also be nil if RuboCop process crashes, e.g. due to
diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb
index 9c20cc7c6..0f6bdb834 100644
--- a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb
@@ -96,9 +96,12 @@ module Superenv
self["SDKROOT"] = MacOS.sdk_path
end
- # Filter out symbols known not to be defined on 10.11 since GNU Autotools
- # can't reliably figure this out with Xcode 8 on its own yet.
- if MacOS.version == "10.11" && MacOS::Xcode.installed? && MacOS::Xcode.version >= "8.0"
+ # Filter out symbols known not to be defined since GNU Autotools can't
+ # reliably figure this out with Xcode 8 and above.
+ if MacOS.version == "10.12" && MacOS::Xcode.installed? && MacOS::Xcode.version >= "9.0"
+ ENV["ac_cv_func_futimens"] = "no"
+ ENV["ac_cv_func_utimensat"] = "no"
+ elsif MacOS.version == "10.11" && MacOS::Xcode.installed? && MacOS::Xcode.version >= "8.0"
%w[basename_r clock_getres clock_gettime clock_settime dirname_r
getentropy mkostemp mkostemps timingsafe_bcmp].each do |s|
ENV["ac_cv_func_#{s}"] = "no"
diff --git a/Library/Homebrew/os/mac/linkage_checker.rb b/Library/Homebrew/os/mac/linkage_checker.rb
index 786827852..f6aa4c2f3 100644
--- a/Library/Homebrew/os/mac/linkage_checker.rb
+++ b/Library/Homebrew/os/mac/linkage_checker.rb
@@ -5,7 +5,7 @@ require "formula"
class LinkageChecker
attr_reader :keg, :formula
attr_reader :brewed_dylibs, :system_dylibs, :broken_dylibs, :variable_dylibs
- attr_reader :undeclared_deps, :reverse_links
+ attr_reader :undeclared_deps, :unnecessary_deps, :reverse_links
def initialize(keg, formula = nil)
@keg = keg
@@ -16,6 +16,7 @@ class LinkageChecker
@variable_dylibs = Set.new
@undeclared_deps = []
@reverse_links = Hash.new { |h, k| h[k] = Set.new }
+ @unnecessary_deps = []
check_dylibs
end
@@ -51,7 +52,7 @@ class LinkageChecker
end
end
- @undeclared_deps = check_undeclared_deps if formula
+ @undeclared_deps, @unnecessary_deps = check_undeclared_deps if formula
end
def check_undeclared_deps
@@ -77,6 +78,12 @@ class LinkageChecker
a <=> b
end
end
+ unnecessary_deps = declared_dep_names.reject do |full_name|
+ name = full_name.split("/").last
+ next true if Formula[name].bin.directory?
+ @brewed_dylibs.keys.map { |x| x.split("/").last }.include?(name)
+ end
+ [undeclared_deps, unnecessary_deps]
end
def display_normal_output
@@ -84,7 +91,8 @@ class LinkageChecker
display_items "Homebrew libraries", @brewed_dylibs
display_items "Variable-referenced libraries", @variable_dylibs
display_items "Missing libraries", @broken_dylibs
- display_items "Possible undeclared dependencies", @undeclared_deps
+ display_items "Undeclared dependencies with linkage", @undeclared_deps
+ display_items "Dependencies with no linkage", @unnecessary_deps
end
def display_reverse_output
@@ -102,6 +110,7 @@ class LinkageChecker
def display_test_output
display_items "Missing libraries", @broken_dylibs
+ display_items "Possible unnecessary dependencies", @unnecessary_deps
puts "No broken dylib links" if @broken_dylibs.empty?
end
@@ -113,6 +122,10 @@ class LinkageChecker
!@undeclared_deps.empty?
end
+ def unnecessary_deps?
+ !@unnecessary_deps.empty?
+ end
+
private
# Whether or not dylib is a harmless broken link, meaning that it's
diff --git a/Library/Homebrew/test/cask/cask_spec.rb b/Library/Homebrew/test/cask/cask_spec.rb
index a6ecc207f..5858a7c6d 100644
--- a/Library/Homebrew/test/cask/cask_spec.rb
+++ b/Library/Homebrew/test/cask/cask_spec.rb
@@ -171,4 +171,38 @@ describe Hbc::Cask, :cask do
end
end
end
+
+ describe "full_name" do
+ context "when it is a core cask" do
+ it "is the cask token" do
+ c = Hbc::CaskLoader.load("local-caffeine")
+ expect(c.full_name).to eq("local-caffeine")
+ end
+ end
+
+ context "when it is from a non-core tap" do
+ it "returns the fully-qualified name of the cask" do
+ c = Hbc::CaskLoader.load("third-party/tap/third-party-cask")
+ expect(c.full_name).to eq("third-party/tap/third-party-cask")
+ end
+ end
+
+ context "when it is from no known tap" do
+ it "retuns the cask token" do
+ file = Tempfile.new(%w[tapless-cask .rb])
+
+ begin
+ cask_name = File.basename(file.path, ".rb")
+ file.write "cask '#{cask_name}'"
+ file.close
+
+ c = Hbc::CaskLoader.load(file.path)
+ expect(c.full_name).to eq(cask_name)
+ ensure
+ file.close
+ file.unlink
+ end
+ end
+ end
+ end
end
diff --git a/Library/Homebrew/test/cask/cli/list_spec.rb b/Library/Homebrew/test/cask/cli/list_spec.rb
index fd6997f41..d2d7efd3b 100644
--- a/Library/Homebrew/test/cask/cli/list_spec.rb
+++ b/Library/Homebrew/test/cask/cli/list_spec.rb
@@ -14,6 +14,26 @@ describe Hbc::CLI::List, :cask do
EOS
end
+ it "lists full names" do
+ casks = %w[
+ local-caffeine
+ third-party/tap/third-party-cask
+ local-transmission
+ ].map { |c| Hbc::CaskLoader.load(c) }
+
+ casks.each do |c|
+ InstallHelper.install_with_caskfile(c)
+ end
+
+ expect {
+ Hbc::CLI::List.run("--full-name")
+ }.to output(<<-EOS.undent).to_stdout
+ local-caffeine
+ local-transmission
+ third-party/tap/third-party-cask
+ EOS
+ end
+
describe "lists versions" do
let(:casks) { ["local-caffeine", "local-transmission"] }
let(:expected_output) {
diff --git a/Library/Homebrew/test/support/fixtures/third-party/Casks/third-party-cask.rb b/Library/Homebrew/test/support/fixtures/third-party/Casks/third-party-cask.rb
new file mode 100644
index 000000000..d7add0522
--- /dev/null
+++ b/Library/Homebrew/test/support/fixtures/third-party/Casks/third-party-cask.rb
@@ -0,0 +1,9 @@
+cask 'third-party-cask' do
+ version '1.2.3'
+ sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
+
+ url 'http://example.com/ThirdParty.dmg'
+ homepage 'http://example.com/'
+
+ app 'ThirdParty.app'
+end
diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb
index c51d339a7..fc83149d0 100644
--- a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb
+++ b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb
@@ -18,6 +18,7 @@ HOMEBREW_CASK_DIRS = [
RSpec.shared_context "Homebrew-Cask" do
around(:each) do |example|
+ third_party_tap = Tap.fetch("third-party", "tap")
begin
dirs = HOMEBREW_CASK_DIRS.map do |dir|
Pathname.new(TEST_TMPDIR).join("cask-#{dir}").tap do |path|
@@ -31,11 +32,18 @@ RSpec.shared_context "Homebrew-Cask" do
FileUtils.ln_sf TEST_FIXTURE_DIR.join("cask"), tap.path
end
+ third_party_tap.tap do |tap|
+ FileUtils.mkdir_p tap.path.dirname
+ FileUtils.ln_sf TEST_FIXTURE_DIR.join("third-party"), tap.path
+ end
+
example.run
ensure
FileUtils.rm_rf dirs
Hbc.default_tap.path.unlink
FileUtils.rm_rf Hbc.default_tap.path.parent
+ third_party_tap.path.unlink
+ FileUtils.rm_rf third_party_tap.path.parent
end
end
end
diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb
index 37bd83c4f..3b5355b15 100644
--- a/Library/Homebrew/test/utils_spec.rb
+++ b/Library/Homebrew/test/utils_spec.rb
@@ -296,4 +296,33 @@ describe "globally-scoped helper methods" do
expect(ENV["PATH"]).not_to eq("/bin")
end
end
+
+ describe "#tap_and_name_comparison" do
+ describe "both strings are only names" do
+ it "alphabetizes the strings" do
+ expect(%w[a b].sort(&tap_and_name_comparison)).to eq(%w[a b])
+ expect(%w[b a].sort(&tap_and_name_comparison)).to eq(%w[a b])
+ end
+ end
+
+ describe "both strings include tap" do
+ it "alphabetizes the strings" do
+ expect(%w[a/z/z b/z/z].sort(&tap_and_name_comparison)).to eq(%w[a/z/z b/z/z])
+ expect(%w[b/z/z a/z/z].sort(&tap_and_name_comparison)).to eq(%w[a/z/z b/z/z])
+
+ expect(%w[z/a/z z/b/z].sort(&tap_and_name_comparison)).to eq(%w[z/a/z z/b/z])
+ expect(%w[z/b/z z/a/z].sort(&tap_and_name_comparison)).to eq(%w[z/a/z z/b/z])
+
+ expect(%w[z/z/a z/z/b].sort(&tap_and_name_comparison)).to eq(%w[z/z/a z/z/b])
+ expect(%w[z/z/b z/z/a].sort(&tap_and_name_comparison)).to eq(%w[z/z/a z/z/b])
+ end
+ end
+
+ describe "only one string includes tap" do
+ it "prefers the string without tap" do
+ expect(%w[a/z/z z].sort(&tap_and_name_comparison)).to eq(%w[z a/z/z])
+ expect(%w[z a/z/z].sort(&tap_and_name_comparison)).to eq(%w[z a/z/z])
+ end
+ end
+ end
end
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 07e339576..3033eb4dd 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -560,3 +560,15 @@ end
def shell_profile
Utils::Shell.profile
end
+
+def tap_and_name_comparison
+ proc do |a, b|
+ if a.include?("/") && !b.include?("/")
+ 1
+ elsif !a.include?("/") && b.include?("/")
+ -1
+ else
+ a <=> b
+ end
+ end
+end