Remove ARGV.filter_for_dependencies

This commit is contained in:
Jack Nagel 2014-06-19 21:35:47 -05:00
parent 10fda9e9b9
commit 445dd80e44
3 changed files with 32 additions and 64 deletions

View File

@ -161,15 +161,6 @@ module HomebrewArgvExtension
Homebrew.help_s
end
def filter_for_dependencies
old_args = clone
delete "--devel"
delete "--HEAD"
yield
ensure
replace(old_args)
end
def cc
value 'cc'
end

View File

@ -255,26 +255,24 @@ class FormulaInstaller
while f = formulae.pop
ARGV.filter_for_dependencies do
f.recursive_requirements do |dependent, req|
build = effective_build_options_for(dependent)
f.recursive_requirements do |dependent, req|
build = effective_build_options_for(dependent)
if (req.optional? || req.recommended?) && build.without?(req)
Requirement.prune
elsif req.build? && dependent == f && pour_bottle?
Requirement.prune
elsif req.build? && dependent != f && install_bottle_for_dep?(dependent, build)
Requirement.prune
elsif req.satisfied?
Requirement.prune
elsif req.default_formula?
dep = req.to_dependency
deps.unshift(dep)
formulae.unshift(dep.to_formula)
Requirement.prune
else
unsatisfied_reqs[dependent] << req
end
if (req.optional? || req.recommended?) && build.without?(req)
Requirement.prune
elsif req.build? && dependent == f && pour_bottle?
Requirement.prune
elsif req.build? && dependent != f && install_bottle_for_dep?(dependent, build)
Requirement.prune
elsif req.satisfied?
Requirement.prune
elsif req.default_formula?
dep = req.to_dependency
deps.unshift(dep)
formulae.unshift(dep.to_formula)
Requirement.prune
else
unsatisfied_reqs[dependent] << req
end
end
end
@ -285,23 +283,21 @@ class FormulaInstaller
def expand_dependencies(deps)
inherited_options = {}
expanded_deps = ARGV.filter_for_dependencies do
Dependency.expand(f, deps) do |dependent, dep|
options = inherited_options[dep.name] = inherited_options_for(dep)
build = effective_build_options_for(
dependent,
inherited_options.fetch(dependent.name, [])
)
expanded_deps = Dependency.expand(f, deps) do |dependent, dep|
options = inherited_options[dep.name] = inherited_options_for(dep)
build = effective_build_options_for(
dependent,
inherited_options.fetch(dependent.name, [])
)
if (dep.optional? || dep.recommended?) && build.without?(dep)
Dependency.prune
elsif dep.build? && dependent == f && pour_bottle?
Dependency.prune
elsif dep.build? && dependent != f && install_bottle_for_dep?(dependent, build)
Dependency.prune
elsif dep.satisfied?(options)
Dependency.skip
end
if (dep.optional? || dep.recommended?) && build.without?(dep)
Dependency.prune
elsif dep.build? && dependent == f && pour_bottle?
Dependency.prune
elsif dep.build? && dependent != f && install_bottle_for_dep?(dependent, build)
Dependency.prune
elsif dep.satisfied?(options)
Dependency.skip
end
end
@ -333,9 +329,7 @@ class FormulaInstaller
oh1 "Installing dependencies for #{f}: #{Tty.green}#{deps.map(&:first)*", "}#{Tty.reset}"
end
ARGV.filter_for_dependencies do
deps.each { |dep, options| install_dependency(dep, options) }
end
deps.each { |dep, options| install_dependency(dep, options) }
@show_header = true unless deps.empty?
end

View File

@ -47,21 +47,4 @@ class ArgvExtensionTests < Homebrew::TestCase
assert !@argv.flag?("--frotz")
assert !@argv.flag?("--debug")
end
def test_filter_for_dependencies_clears_flags
@argv << "--HEAD" << "--devel"
@argv.filter_for_dependencies { assert_empty @argv }
end
def test_filter_for_dependencies_ensures_argv_restored
@argv.expects(:replace).with(@argv.clone)
begin
@argv.filter_for_dependencies { raise Exception }
rescue Exception
end
end
def test_filter_for_dependencies_returns_block_value
assert_equal 1, @argv.filter_for_dependencies { 1 }
end
end