diff options
| author | Jack Nagel | 2013-07-22 21:36:11 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-07-22 21:36:11 -0500 |
| commit | fcfc53df3314136cd8298e8971ea41d7402b7064 (patch) | |
| tree | c4f482f14b3eab5e49bce874301b20ecf7c01051 /Library | |
| parent | 1fb4cd501b58aeba30dbf903a496d1606da27868 (diff) | |
| download | brew-fcfc53df3314136cd8298e8971ea41d7402b7064.tar.bz2 | |
Check deps of satisfied deps
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/dependency.rb | 15 | ||||
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_dependency_expansion.rb | 13 |
3 files changed, 25 insertions, 5 deletions
diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 407623810..c63e26f3f 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -71,8 +71,11 @@ class Dependency # optionals and recommendeds based on what the dependent has asked for. def expand(dependent, &block) deps = dependent.deps.map do |dep| - if prune?(dependent, dep, &block) + case action(dependent, dep, &block) + when :prune next + when :skip + expand(dep.to_formula, &block) else expand(dep.to_formula, &block) << dep end @@ -81,8 +84,8 @@ class Dependency merge_repeats(deps) end - def prune?(dependent, dep, &block) - catch(:prune) do + def action(dependent, dep, &block) + catch(:action) do if block_given? yield dependent, dep elsif dep.optional? || dep.recommended? @@ -93,7 +96,11 @@ class Dependency # Used to prune dependencies when calling expand with a block. def prune - throw(:prune, true) + throw(:action, :prune) + end + + def skip + throw(:action, :skip) end def merge_repeats(deps) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 33bc97180..d4e4e8dcc 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -178,7 +178,7 @@ class FormulaInstaller elsif dep.build? && install_bottle?(dependent) Dependency.prune elsif dep.satisfied? - Dependency.prune + Dependency.skip elsif dep.installed? raise UnsatisfiedDependencyError.new(f, dep) end diff --git a/Library/Homebrew/test/test_dependency_expansion.rb b/Library/Homebrew/test/test_dependency_expansion.rb index d0dada2e0..90d4dcc36 100644 --- a/Library/Homebrew/test/test_dependency_expansion.rb +++ b/Library/Homebrew/test/test_dependency_expansion.rb @@ -82,4 +82,17 @@ class DependencyExpansionTests < Test::Unit::TestCase assert_equal %w{option}, Dependency.expand(@f).first.tags end + + def test_skip_skips_parent_but_yields_children + f = stub(:deps => [ + build_dep(:foo, [], [@bar, @baz]), + build_dep(:foo, [], [@baz]), + ]) + + deps = Dependency.expand(f) do |dependent, dep| + Dependency.skip if %w{foo qux}.include? dep.name + end + + assert_equal [@bar, @baz], deps + end end |
