diff options
| author | Adam Vandenberg | 2010-02-18 11:40:59 -0800 |
|---|---|---|
| committer | Adam Vandenberg | 2010-04-06 08:27:10 -0700 |
| commit | 3123720608078375a1e141d1db1f32f42a48026f (patch) | |
| tree | 6a3a9f11de2769fde0ff66aa5be705b0c4153e18 /Library | |
| parent | 9d127ac3d58f99a744fe017f89ca64dcaeeed778 (diff) | |
| download | brew-3123720608078375a1e141d1db1f32f42a48026f.tar.bz2 | |
Move install tests to separate file.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/test_bucket.rb | 45 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formula_install.rb | 96 | ||||
| -rwxr-xr-x | Library/Homebrew/test/tests | 3 | ||||
| -rwxr-xr-x | Library/Homebrew/test/unittest.rb | 11 |
4 files changed, 99 insertions, 56 deletions
diff --git a/Library/Homebrew/test/test_bucket.rb b/Library/Homebrew/test/test_bucket.rb index 7d249c278..cc615466b 100644 --- a/Library/Homebrew/test/test_bucket.rb +++ b/Library/Homebrew/test/test_bucket.rb @@ -37,51 +37,6 @@ class BeerTasting < Test::Unit::TestCase assert_raises(RuntimeError) {f=TestBadVersion.new} end - def test_install - f=TestBall.new - - assert_equal Formula.path(f.name), f.path - assert !f.installed? - - nostdout do - f.brew do - f.install - end - end - - assert_match Regexp.new("^#{HOMEBREW_CELLAR}/"), f.prefix.to_s - - assert f.bin.directory? - assert_equal 3, f.bin.children.length - libexec=f.prefix+'libexec' - assert libexec.directory? - assert_equal 1, libexec.children.length - assert !(f.prefix+'main.c').exist? - assert f.installed? - - keg=Keg.new f.prefix - keg.link - assert_equal 2, HOMEBREW_PREFIX.children.length - assert (HOMEBREW_PREFIX+'bin').directory? - assert_equal 3, (HOMEBREW_PREFIX+'bin').children.length - - keg.uninstall - assert !keg.exist? - assert !f.installed? - end - - def test_script_install - f=TestScriptFileFormula.new - - nostdout do - f.brew do - f.install - end - end - - assert_equal 1, f.bin.children.length - end - FOOBAR='foo-bar' def test_formula_funcs classname=Formula.class_s(FOOBAR) diff --git a/Library/Homebrew/test/test_formula_install.rb b/Library/Homebrew/test/test_formula_install.rb new file mode 100644 index 000000000..fcf5fec54 --- /dev/null +++ b/Library/Homebrew/test/test_formula_install.rb @@ -0,0 +1,96 @@ +require 'testing_env' + +require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser +ARGV.extend(HomebrewArgvExtension) + +require 'formula' +require 'keg' +require 'utils' + + +class TestBall <Formula + # name parameter required for some Formula::factory + def initialize name=nil + @url="file:///#{TEST_FOLDER}/testball-0.1.tbz" + @homepage = 'http://example.com/' + super "testball" + end + def install + prefix.install "bin" + prefix.install "libexec" + end +end + + +class TestScriptFileFormula <ScriptFileFormula + url "file:///#{Pathname.new(ABS__FILE__).realpath}" + version "1" + + def initialize + @name='test-script-formula' + @homepage = 'http://example.com/' + super + end +end + + +class InstallTests < Test::Unit::TestCase + def temporary_install f + # Brew and install the given formula + nostdout do + f.brew { f.install } + end + + # Allow the test to do some processing + yield + + # Remove the brewed formula and double check + # that it did get removed. This lets multiple + # tests use the same formula name without + # stepping on each other. + keg=Keg.new f.prefix + keg.uninstall + assert !keg.exist? + assert !f.installed? + end + + def test_a_basic_install + f=TestBall.new + + assert_equal Formula.path(f.name), f.path + assert !f.installed? + + temporary_install f do + assert_match Regexp.new("^#{HOMEBREW_CELLAR}/"), f.prefix.to_s + + # Test that things made it into the Keg + assert f.bin.directory? + assert_equal 3, f.bin.children.length + libexec=f.prefix+'libexec' + assert libexec.directory? + assert_equal 1, libexec.children.length + assert !(f.prefix+'main.c').exist? + assert f.installed? + + # Test that things make it into the Cellar + keg=Keg.new f.prefix + keg.link + assert_equal 2, HOMEBREW_PREFIX.children.length + assert (HOMEBREW_PREFIX+'bin').directory? + assert_equal 3, (HOMEBREW_PREFIX+'bin').children.length + end + end + + def test_script_install + f=TestScriptFileFormula.new + + temporary_install f do + nostdout do + f.brew { f.install } + end + + assert_equal 1, f.bin.children.length + end + end + +end diff --git a/Library/Homebrew/test/tests b/Library/Homebrew/test/tests index 64aaf3109..ea5cf6cea 100755 --- a/Library/Homebrew/test/tests +++ b/Library/Homebrew/test/tests @@ -9,6 +9,9 @@ # Bulk of the tests ruby unittest.rb $* +# Test formula installs +ruby test_formula_install.rb $* + # Update tests (only seem to work for mxcl) ruby test_updater.rb $* diff --git a/Library/Homebrew/test/unittest.rb b/Library/Homebrew/test/unittest.rb index 49d6f6ad7..cfe8bc128 100755 --- a/Library/Homebrew/test/unittest.rb +++ b/Library/Homebrew/test/unittest.rb @@ -101,17 +101,6 @@ class TestBallOverrideBrew <Formula end end -class TestScriptFileFormula <ScriptFileFormula - url "file:///#{Pathname.new(ABS__FILE__).realpath}" - version "1" - - def initialize - @name='test-script-formula' - @homepage = 'http://example.com/' - super - end -end - module ExtendArgvPlusYeast def reset @named = nil |
