tab: remove #reliable_runtime_dependencies?

See https://github.com/Homebrew/brew/pull/1750#discussion_r94243825 for
discussion.

Removes Tab#reliable_runtime_dependencies? in favour of returning nil
from Tab#runtime_dependencies if the list is unreliable.

Because Homebrew 1.1.6 hasn't been tagged yet, tabs created in tests
aren't created with a homebrew_version that marks the
runtime_dependencies in the Tab as reliable, so there are some tests
that fail. To work around this, I've had to add a line to some tests
that explicitly overrides the homebrew_version in the Tab. This is
really ugly though, so they should be removed as soon as possible after
1.1.6 is released.
This commit is contained in:
Alyssa Ross 2016-12-30 20:34:14 +00:00
parent 4322c1c562
commit d998a3fcce
3 changed files with 22 additions and 20 deletions

View File

@ -104,10 +104,8 @@ class Keg
# so need them to be calculated now.
#
# This happens after the initial dependency check because it's sloooow.
remaining_formulae = Formula.installed.reject do |f|
f.installed_kegs.all? do |k|
Tab.for_keg(k).reliable_runtime_dependencies?
end
remaining_formulae = Formula.installed.select do |f|
f.installed_kegs.any? { |k| Tab.for_keg(k).runtime_dependencies.nil? }
end
keg_names = kegs.map(&:name)
@ -362,7 +360,7 @@ class Keg
tap = Tab.for_keg(self).source["tap"]
Keg.all.select do |keg|
tab = Tab.for_keg(keg)
next unless tab.reliable_runtime_dependencies?
next if tab.runtime_dependencies.nil?
tab.runtime_dependencies.any? do |dep|
# Resolve formula rather than directly comparing names
# in case of conflicts between formulae from different taps.

View File

@ -247,15 +247,10 @@ class Tab < OpenStruct
Version.new(homebrew_version)
end
# Whether there is reliable runtime dependency information in the receipt.
def reliable_runtime_dependencies?
return false if runtime_dependencies.nil?
def runtime_dependencies
# Homebrew versions prior to 1.1.6 generated incorrect runtime dependency
# lists.
return false if parsed_homebrew_version < "1.1.6"
true
super unless parsed_homebrew_version < "1.1.6"
end
def cxxstdlib

View File

@ -32,6 +32,11 @@ class TabTests < Homebrew::TestCase
def test_defaults
tab = Tab.empty
# FIXME: remove this line after Homebrew 1.1.6 is released.
# See https://github.com/Homebrew/brew/pull/1750#discussion_r94254622
tab.homebrew_version = "1.1.6"
assert_empty tab.unused_options
assert_empty tab.used_options
assert_nil tab.changed_files
@ -89,27 +94,27 @@ class TabTests < Homebrew::TestCase
assert tab.parsed_homebrew_version < "2.0.0-135-g01789abdf"
end
def test_reliable_runtime_dependencies?
def test_runtime_dependencies
tab = Tab.new
refute_predicate tab, :reliable_runtime_dependencies?
assert_nil tab.runtime_dependencies
tab.homebrew_version = "1.1.6"
refute_predicate tab, :reliable_runtime_dependencies?
assert_nil tab.runtime_dependencies
tab.runtime_dependencies = []
assert_predicate tab, :reliable_runtime_dependencies?
refute_nil tab.runtime_dependencies
tab.homebrew_version = "1.1.5"
refute_predicate tab, :reliable_runtime_dependencies?
assert_nil tab.runtime_dependencies
tab.homebrew_version = "1.1.7"
assert_predicate tab, :reliable_runtime_dependencies?
refute_nil tab.runtime_dependencies
tab.homebrew_version = "1.1.10"
assert_predicate tab, :reliable_runtime_dependencies?
refute_nil tab.runtime_dependencies
tab.runtime_dependencies = [{ "full_name" => "foo", "version" => "1.0" }]
assert_predicate tab, :reliable_runtime_dependencies?
refute_nil tab.runtime_dependencies
end
def test_cxxstdlib
@ -194,6 +199,10 @@ class TabTests < Homebrew::TestCase
stdlib = :libcxx
tab = Tab.create(f, compiler, stdlib)
# FIXME: remove this line after Homebrew 1.1.6 is released.
# See https://github.com/Homebrew/brew/pull/1750#discussion_r94254622
tab.homebrew_version = "1.1.6"
runtime_dependencies = [
{ "full_name" => "bar", "version" => "2.0" },
{ "full_name" => "user/repo/from_tap", "version" => "1.0" },