Support jruby external dependencies.
* Add tests that run only if 'jruby' is installed. * Note that if your formula has :jruby deps, it should likely "depend_on 'jruby'" as well.
This commit is contained in:
parent
72ef9f4aaa
commit
cfc8fca74d
@ -475,7 +475,7 @@ private
|
||||
|
||||
def depends_on name
|
||||
@deps ||= []
|
||||
@external_deps ||= {:python => [], :ruby => [], :perl => []}
|
||||
@external_deps ||= {:python => [], :perl => [], :ruby => [], :jruby => []}
|
||||
|
||||
case name
|
||||
when String
|
||||
@ -483,7 +483,7 @@ private
|
||||
when Hash
|
||||
key, value = name.shift
|
||||
case value
|
||||
when :python, :ruby, :perl
|
||||
when :python, :perl, :ruby, :jruby
|
||||
@external_deps[value] << key
|
||||
return
|
||||
when :optional, :recommended
|
||||
|
@ -43,6 +43,13 @@ Homebrew does not provide formulae for Ruby dependencies, rubygems does:
|
||||
gem install #{dep}
|
||||
EOS
|
||||
end
|
||||
def jrberr dep; <<-EOS
|
||||
Unsatisfied dependency "#{dep}"
|
||||
Homebrew does not provide formulae for JRuby dependencies, rubygems does:
|
||||
|
||||
jruby -S gem install #{dep}
|
||||
EOS
|
||||
end
|
||||
|
||||
def check_external_deps f
|
||||
return unless f.external_deps
|
||||
@ -56,6 +63,9 @@ Homebrew does not provide formulae for Ruby dependencies, rubygems does:
|
||||
f.external_deps[:ruby].each do |dep|
|
||||
raise rberr(dep) unless quiet_system "/usr/bin/env", "ruby", "-rubygems", "-e", "require '#{dep}'"
|
||||
end
|
||||
f.external_deps[:jruby].each do |dep|
|
||||
raise rberr(dep) unless quiet_system "/usr/bin/env", "jruby", "-rubygems", "-e", "require '#{dep}'"
|
||||
end
|
||||
end
|
||||
|
||||
def check_formula_deps f
|
||||
|
@ -27,6 +27,10 @@ class DontActuallyInstall < FormulaInstaller
|
||||
def rberr dep
|
||||
"Ruby module install message."
|
||||
end
|
||||
|
||||
def jrberr dep
|
||||
"JRuby module install message."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -79,6 +83,22 @@ class GoodRubyBall <TestBall
|
||||
end
|
||||
end
|
||||
|
||||
class BadJRubyBall <TestBall
|
||||
depends_on "notapackage" => :jruby
|
||||
|
||||
def initialize name=nil
|
||||
super "uses_jruby_ball"
|
||||
end
|
||||
end
|
||||
|
||||
class GoodJRubyBall <TestBall
|
||||
depends_on "date" => :jruby
|
||||
|
||||
def initialize name=nil
|
||||
super "uses_jruby_ball"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class ExternalDepsTests < Test::Unit::TestCase
|
||||
def check_deps_fail f
|
||||
@ -117,4 +137,13 @@ class ExternalDepsTests < Test::Unit::TestCase
|
||||
def test_good_ruby_deps
|
||||
check_deps_pass GoodRubyBall
|
||||
end
|
||||
|
||||
# Only run these next two tests if jruby is installed.
|
||||
def test_bad_jruby_deps
|
||||
check_deps_fail BadJRubyBall unless `/usr/bin/which jruby`.chomp.empty?
|
||||
end
|
||||
|
||||
def test_good_jruby_deps
|
||||
check_deps_pass GoodJRubyBall unless `/usr/bin/which jruby`.chomp.empty?
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user