diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/brew.h.rb | 27 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 2 | ||||
| -rwxr-xr-x | Library/Homebrew/unittest.rb | 23 |
3 files changed, 43 insertions, 9 deletions
diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index 8b3939968..496e7afc0 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -144,6 +144,33 @@ def clean f end +# NOTE this is ugly code, and inefficient too, and can have infinite cycles +# I have no time currently to improve it, feel free to submit a more elegant +# solution. Thanks! --mxcl +def expand_deps fae + deps = [] + fae.each do |f| + case f.deps + when String, Array + f.deps.each do |name| + f = Formula.factory name + deps << expand_deps(f) if f.deps # hideous inefficient + deps << f + end + when Hash + # TODO implement optional and recommended + names = [] + f.deps.each_value {|v| names << v} + ff=names.flatten.collect {|name| Formula.factory name} + deps << expand_deps(ff) + end + deps << f + end + # TODO much more efficient to use a set and not recurse stuff already done + return deps.flatten.uniq +end + + def install f f.brew do if ARGV.flag? '--interactive' diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 7faabbae6..9c5123545 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -123,7 +123,7 @@ class Formula def brew validate_variable :name validate_variable :version - + stage do begin patch diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb index ae8b0c1bc..2738755e4 100755 --- a/Library/Homebrew/unittest.rb +++ b/Library/Homebrew/unittest.rb @@ -41,7 +41,8 @@ class MostlyAbstractFormula <Formula end class TestBall <Formula - def initialize + # name parameter required for some Formula::factory + def initialize name=nil @url="file:///#{Pathname.new(ABS__FILE__).parent.realpath}/testball-0.1.tbz" super "testball" end @@ -98,9 +99,13 @@ def nostdout end module ExtendArgvPlusYeast - def stick_an_arg_in_thar + def reset @named=nil - unshift 'foo' + @formulae=nil + @kegs=nil + while ARGV.count > 0 + ARGV.shift + end end end ARGV.extend ExtendArgvPlusYeast @@ -347,8 +352,9 @@ class BeerTasting <Test::Unit::TestCase end def test_no_ARGV_dupes - ARGV.unshift'foo' - ARGV.unshift'foo' + ARGV.reset + ARGV.unshift 'foo' + ARGV.unshift 'foo' n=0 ARGV.named.each{|arg| n+=1 if arg == 'foo'} assert_equal 1, n @@ -360,9 +366,10 @@ class BeerTasting <Test::Unit::TestCase assert_raises(UsageError) { ARGV.kegs } assert ARGV.named_empty? - (HOMEBREW_CELLAR+'foo'+'0.1').mkpath + (HOMEBREW_CELLAR+'mxcl'+'10.0').mkpath - ARGV.stick_an_arg_in_thar + ARGV.reset + ARGV.unshift 'mxcl' assert_equal 1, ARGV.named.length assert_equal 1, ARGV.kegs.length assert_raises(FormulaUnavailableError) { ARGV.formulae } @@ -395,7 +402,7 @@ class BeerTasting <Test::Unit::TestCase nostdout do assert_nothing_raised do f=TestBall.new - make 'http://example.com/testball-0.1.tbz' + make f.url info f.name clean f prune |
