diff options
| author | Adam Vandenberg | 2010-02-13 10:26:15 -0800 |
|---|---|---|
| committer | Adam Vandenberg | 2010-04-06 08:27:11 -0700 |
| commit | ccdffb2c31d00ea0d79b04d1e63d1085233012a0 (patch) | |
| tree | 41ddfaf9f07a82e28a9c77622de43a73638ce96f /Library | |
| parent | 1f82fe4dc7acb1edd81fa41b9fa3829c7d1b9c12 (diff) | |
| download | brew-ccdffb2c31d00ea0d79b04d1e63d1085233012a0.tar.bz2 | |
Add external deps. tests.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/test_external_deps.rb | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_external_deps.rb b/Library/Homebrew/test/test_external_deps.rb new file mode 100644 index 000000000..373d334ba --- /dev/null +++ b/Library/Homebrew/test/test_external_deps.rb @@ -0,0 +1,120 @@ +require 'testing_env' + +require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser +ARGV.extend(HomebrewArgvExtension) + +require 'test/testball' +require 'formula_installer' +require 'utils' + + +# Custom formula installer that checks deps but does not +# run the install code. We also override the external dep +# install messages, so for instance the Python check doesnt +# look for the pip formula (which isn't avaialble in test +# mode.) +class DontActuallyInstall < FormulaInstaller + def install_private f ; end + + def pyerr dep + "Python module install message." + end + + def plerr dep + "Perl module install message." + end + + def rberr dep + "Ruby module install message." + end +end + + + +class BadPerlBall <TestBall + depends_on "notapackage" => :perl + + def initialize name=nil + super "uses_perl_ball" + end +end + +class GoodPerlBall <TestBall + depends_on "ENV" => :perl + + def initialize name=nil + super "uses_perl_ball" + end +end + +class BadPythonBall <TestBall + depends_on "notapackage" => :python + + def initialize name=nil + super "uses_python_ball" + end +end + +class GoodPythonBall <TestBall + depends_on "datetime" => :python + + def initialize name=nil + super "uses_python_ball" + end +end + +class BadRubyBall <TestBall + depends_on "notapackage" => :ruby + + def initialize name=nil + super "uses_ruby_ball" + end +end + +class GoodRubyBall <TestBall + depends_on "date" => :ruby + + def initialize name=nil + super "uses_ruby_ball" + end +end + + +class ExternalDepsTests < Test::Unit::TestCase + def check_deps_fail f + assert_raises(RuntimeError) do + DontActuallyInstall.new.install f.new + end + end + + def check_deps_pass f + assert_nothing_raised do + DontActuallyInstall.new.install f.new + end + end + + + def test_bad_perl_deps + check_deps_fail BadPerlBall + end + + def test_good_perl_deps + check_deps_pass GoodPerlBall + end + + def test_bad_python_deps + check_deps_fail BadPythonBall + end + + def test_good_python_deps + check_deps_pass GoodPythonBall + end + + def test_bad_ruby_deps + check_deps_fail BadRubyBall + end + + def test_good_ruby_deps + check_deps_pass GoodRubyBall + end +end |
