diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/test_bucket.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_versions.rb | 115 | ||||
| -rwxr-xr-x | Library/Homebrew/test/tests | 2 | ||||
| -rwxr-xr-x | Library/Homebrew/test/unittest.rb | 5 |
4 files changed, 73 insertions, 58 deletions
diff --git a/Library/Homebrew/test/test_bucket.rb b/Library/Homebrew/test/test_bucket.rb index 39dd41dab..d2826efce 100644 --- a/Library/Homebrew/test/test_bucket.rb +++ b/Library/Homebrew/test/test_bucket.rb @@ -28,15 +28,6 @@ class BeerTasting < Test::Unit::TestCase end end - def test_no_version - assert_nil Pathname.new("http://example.com/blah.tar").version - assert_nil Pathname.new("arse").version - end - - def test_bad_version - assert_raises(RuntimeError) {f=TestBadVersion.new} - end - FOOBAR='foo-bar' def test_formula_funcs classname=Formula.class_s(FOOBAR) diff --git a/Library/Homebrew/test/test_versions.rb b/Library/Homebrew/test/test_versions.rb index 3e55676f5..a02bdb49e 100644 --- a/Library/Homebrew/test/test_versions.rb +++ b/Library/Homebrew/test/test_versions.rb @@ -1,111 +1,138 @@ +require 'testing_env' + +require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser +ARGV.extend(HomebrewArgvExtension) + +require 'formula' +require 'test/testball' + +class MockFormula <Formula + def initialize url + @url=url + @homepage = 'http://example.com/' + super 'test' + end +end + +class TestBadVersion <TestBall + @version="versions can't have spaces" +end + + class VersionTests < Test::Unit::TestCase + def test_pathname_version + d=HOMEBREW_CELLAR+'foo-0.1.9' + d.mkpath + assert_equal '0.1.9', d.version + end + + def test_no_version + assert_nil Pathname.new("http://example.com/blah.tar").version + assert_nil Pathname.new("arse").version + end + + def test_bad_version + assert_raises(RuntimeError) {f=TestBadVersion.new} + end + + def check pathname, version + r=MockFormula.new pathname + assert_equal version, r.version + end + def test_version_all_dots - r=MockFormula.new "http://example.com/foo.bar.la.1.14.zip" - assert_equal '1.14', r.version + check "http://example.com/foo.bar.la.1.14.zip", '1.14' end def test_version_underscore_separator - r=MockFormula.new "http://example.com/grc_1.1.tar.gz" - assert_equal '1.1', r.version + check "http://example.com/grc_1.1.tar.gz", '1.1' end def test_boost_version_style - r=MockFormula.new "http://example.com/boost_1_39_0.tar.bz2" - assert_equal '1.39.0', r.version + check "http://example.com/boost_1_39_0.tar.bz2", '1.39.0' end def test_erlang_version_style - r=MockFormula.new "http://erlang.org/download/otp_src_R13B.tar.gz" - assert_equal 'R13B', r.version + check "http://erlang.org/download/otp_src_R13B.tar.gz", 'R13B' end def test_p7zip_version_style - r=MockFormula.new "http://kent.dl.sourceforge.net/sourceforge/p7zip/p7zip_9.04_src_all.tar.bz2" - assert_equal '9.04', r.version + check "http://kent.dl.sourceforge.net/sourceforge/p7zip/p7zip_9.04_src_all.tar.bz2", + '9.04' end def test_gloox_beta_style - r=MockFormula.new "http://camaya.net/download/gloox-1.0-beta7.tar.bz2" - assert_equal '1.0-beta7', r.version + check "http://camaya.net/download/gloox-1.0-beta7.tar.bz2", '1.0-beta7' end def test_astyle_verson_style - r=MockFormula.new "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz" - assert_equal '1.23', r.version + check "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz", + '1.23' end def test_version_libvorbis - r=MockFormula.new "http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2rc1.tar.bz2" - assert_equal '1.2.2rc1', r.version + check "http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2rc1.tar.bz2", + '1.2.2rc1' end def test_version_dos2unix - r=MockFormula.new "http://www.sfr-fresh.com/linux/misc/dos2unix-3.1.tar.gz" - assert_equal '3.1', r.version + check "http://www.sfr-fresh.com/linux/misc/dos2unix-3.1.tar.gz", '3.1' end def test_version_internal_dash - r=MockFormula.new "http://example.com/foo-arse-1.1-2.tar.gz" - assert_equal '1.1-2', r.version + check "http://example.com/foo-arse-1.1-2.tar.gz", '1.1-2' end def test_version_single_digit - r=MockFormula.new "http://example.com/foo_bar.45.tar.gz" - assert_equal '45', r.version + check "http://example.com/foo_bar.45.tar.gz", '45' end def test_noseparator_single_digit - r=MockFormula.new "http://example.com/foo_bar45.tar.gz" - assert_equal '45', r.version + check "http://example.com/foo_bar45.tar.gz", '45' end def test_version_developer_that_hates_us_format - r=MockFormula.new "http://example.com/foo-bar-la.1.2.3.tar.gz" - assert_equal '1.2.3', r.version + check "http://example.com/foo-bar-la.1.2.3.tar.gz", '1.2.3' end def test_version_regular - r=MockFormula.new "http://example.com/foo_bar-1.21.tar.gz" - assert_equal '1.21', r.version + check "http://example.com/foo_bar-1.21.tar.gz", '1.21' end def test_version_github - r=MockFormula.new "http://github.com/lloyd/yajl/tarball/1.0.5" - assert_equal '1.0.5', r.version + check "http://github.com/lloyd/yajl/tarball/1.0.5", '1.0.5' end def test_version_github_with_high_patch_number - r=MockFormula.new "http://github.com/lloyd/yajl/tarball/v1.2.34" - assert_equal '1.2.34', r.version + check "http://github.com/lloyd/yajl/tarball/v1.2.34", '1.2.34' end def test_yet_another_version - r=MockFormula.new "http://example.com/mad-0.15.1b.tar.gz" - assert_equal '0.15.1b', r.version + check "http://example.com/mad-0.15.1b.tar.gz", '0.15.1b' end def test_lame_version_style - f=MockFormula.new 'http://kent.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz' - assert_equal '398-2', f.version + check 'http://kent.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz', + '398-2' end def test_ruby_version_style - f=MockFormula.new 'ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz' - assert_equal '1.9.1-p243', f.version + check 'ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz', + '1.9.1-p243' end def test_omega_version_style - f=MockFormula.new 'http://www.alcyone.com/binaries/omega/omega-0.80.2-src.tar.gz' - assert_equal '0.80.2', f.version + check 'http://www.alcyone.com/binaries/omega/omega-0.80.2-src.tar.gz', + '0.80.2' end def test_version_style_rc - f=MockFormula.new 'http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz' - assert_equal '1.8.0-rc1', f.version + check 'http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz', + '1.8.0-rc1' end def test_angband_version_style - f = MockFormula.new 'http://rephial.org/downloads/3.0/angband-3.0.9b-src.tar.gz' - assert_equal '3.0.9b', f.version + check 'http://rephial.org/downloads/3.0/angband-3.0.9b-src.tar.gz', + '3.0.9b' end end diff --git a/Library/Homebrew/test/tests b/Library/Homebrew/test/tests index 4afc72621..093433acc 100755 --- a/Library/Homebrew/test/tests +++ b/Library/Homebrew/test/tests @@ -9,6 +9,8 @@ # Bulk of the tests ruby unittest.rb $* +ruby test_versions.rb $* + ruby test_inreplace.rb $* # Test hardware sniffers diff --git a/Library/Homebrew/test/unittest.rb b/Library/Homebrew/test/unittest.rb index b6573c8bd..2b4ab377a 100755 --- a/Library/Homebrew/test/unittest.rb +++ b/Library/Homebrew/test/unittest.rb @@ -85,10 +85,6 @@ class TestZip <Formula end end -class TestBadVersion <TestBall - @version="versions can't have spaces" -end - class TestBallOverrideBrew <Formula def initialize super "foo" @@ -108,6 +104,5 @@ module ExtendArgvPlusYeast end ARGV.extend ExtendArgvPlusYeast -require 'test/test_versions' require 'test/test_checksums' require 'test/test_bucket' |
