2010-02-27 16:03:04 -08:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
class VersionTests < Test::Unit::TestCase
|
2010-02-27 16:03:04 -08:00
|
|
|
def test_pathname_version
|
|
|
|
d=HOMEBREW_CELLAR+'foo-0.1.9'
|
|
|
|
d.mkpath
|
|
|
|
assert_equal '0.1.9', d.version
|
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2010-02-27 16:03:04 -08:00
|
|
|
def test_no_version
|
|
|
|
assert_nil Pathname.new("http://example.com/blah.tar").version
|
|
|
|
assert_nil Pathname.new("arse").version
|
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2010-02-27 16:03:04 -08:00
|
|
|
def test_bad_version
|
|
|
|
assert_raises(RuntimeError) {f=TestBadVersion.new}
|
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2010-02-27 16:03:04 -08:00
|
|
|
def check pathname, version
|
|
|
|
r=MockFormula.new pathname
|
|
|
|
assert_equal version, r.version
|
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
def test_version_all_dots
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://example.com/foo.bar.la.1.14.zip", '1.14'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_version_underscore_separator
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://example.com/grc_1.1.tar.gz", '1.1'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_boost_version_style
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://example.com/boost_1_39_0.tar.bz2", '1.39.0'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_erlang_version_style
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://erlang.org/download/otp_src_R13B.tar.gz", 'R13B'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
def test_p7zip_version_style
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://kent.dl.sourceforge.net/sourceforge/p7zip/p7zip_9.04_src_all.tar.bz2",
|
|
|
|
'9.04'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2012-01-14 03:46:25 +00:00
|
|
|
def test_new_github_style
|
|
|
|
check "https://github.com/sam-github/libnet/tarball/libnet-1.1.4", "1.1.4"
|
|
|
|
end
|
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
def test_gloox_beta_style
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://camaya.net/download/gloox-1.0-beta7.tar.bz2", '1.0-beta7'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2010-08-27 08:42:50 +02:00
|
|
|
def test_sphinx_beta_style
|
|
|
|
check 'http://sphinxsearch.com/downloads/sphinx-1.10-beta.tar.gz', '1.10-beta'
|
|
|
|
end
|
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
def test_astyle_verson_style
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz",
|
|
|
|
'1.23'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
def test_version_dos2unix
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://www.sfr-fresh.com/linux/misc/dos2unix-3.1.tar.gz", '3.1'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_version_internal_dash
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://example.com/foo-arse-1.1-2.tar.gz", '1.1-2'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_version_single_digit
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://example.com/foo_bar.45.tar.gz", '45'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_noseparator_single_digit
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://example.com/foo_bar45.tar.gz", '45'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_version_developer_that_hates_us_format
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://example.com/foo-bar-la.1.2.3.tar.gz", '1.2.3'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_version_regular
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://example.com/foo_bar-1.21.tar.gz", '1.21'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
2011-01-09 22:41:03 -05:00
|
|
|
def test_version_sourceforge_download
|
|
|
|
check "http://sourceforge.net/foo_bar-1.21.tar.gz/download", '1.21'
|
|
|
|
check "http://sf.net/foo_bar-1.21.tar.gz/download", '1.21'
|
|
|
|
end
|
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
def test_version_github
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://github.com/lloyd/yajl/tarball/1.0.5", '1.0.5'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
2010-03-27 15:02:21 -05:00
|
|
|
def test_version_github_with_high_patch_number
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://github.com/lloyd/yajl/tarball/v1.2.34", '1.2.34'
|
2010-03-27 15:02:21 -05:00
|
|
|
end
|
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
def test_yet_another_version
|
2010-02-27 16:03:04 -08:00
|
|
|
check "http://example.com/mad-0.15.1b.tar.gz", '0.15.1b'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_lame_version_style
|
2010-02-27 16:03:04 -08:00
|
|
|
check 'http://kent.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz',
|
|
|
|
'398-2'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
def test_ruby_version_style
|
2010-02-27 16:03:04 -08:00
|
|
|
check 'ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz',
|
|
|
|
'1.9.1-p243'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
def test_omega_version_style
|
2010-02-27 16:03:04 -08:00
|
|
|
check 'http://www.alcyone.com/binaries/omega/omega-0.80.2-src.tar.gz',
|
|
|
|
'0.80.2'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
2010-07-06 11:49:43 -07:00
|
|
|
def test_rc_style
|
|
|
|
check "http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2rc1.tar.bz2",
|
|
|
|
'1.2.2rc1'
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_dash_rc_style
|
2010-02-27 16:03:04 -08:00
|
|
|
check 'http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz',
|
|
|
|
'1.8.0-rc1'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
2010-01-29 10:41:03 -08:00
|
|
|
def test_angband_version_style
|
2010-02-27 16:03:04 -08:00
|
|
|
check 'http://rephial.org/downloads/3.0/angband-3.0.9b-src.tar.gz',
|
|
|
|
'3.0.9b'
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
2010-07-06 11:49:43 -07:00
|
|
|
|
|
|
|
def test_stable_suffix
|
|
|
|
check 'http://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz',
|
|
|
|
'1.4.14b'
|
|
|
|
end
|
2010-07-06 13:12:29 -07:00
|
|
|
|
|
|
|
def test_debian_style_1
|
|
|
|
check 'http://ftp.de.debian.org/debian/pool/main/s/sl/sl_3.03.orig.tar.gz',
|
|
|
|
'3.03'
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_debian_style_2
|
|
|
|
check 'http://ftp.de.debian.org/debian/pool/main/m/mmv/mmv_1.01b.orig.tar.gz',
|
|
|
|
'1.01b'
|
|
|
|
end
|
2011-06-21 18:40:07 +01:00
|
|
|
|
|
|
|
def test_bottle_style
|
2012-03-07 20:44:19 -05:00
|
|
|
check 'https://downloads.sf.net/project/machomebrew/Bottles/qt-4.8.0.lion.bottle.tar.gz',
|
|
|
|
'4.8.0'
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_erlang_bottle_style
|
|
|
|
check 'https://downloads.sf.net/project/machomebrew/Bottles/erlang-R15B.lion.bottle.tar.gz',
|
|
|
|
'R15B'
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_old_bottle_style
|
|
|
|
check 'https://downloads.sf.net/project/machomebrew/Bottles/qt-4.7.3-bottle.tar.gz',
|
2011-06-21 18:40:07 +01:00
|
|
|
'4.7.3'
|
|
|
|
end
|
2011-09-21 17:14:54 -05:00
|
|
|
|
2012-03-07 20:44:19 -05:00
|
|
|
def test_old_erlang_bottle_style
|
|
|
|
check 'https://downloads.sf.net/project/machomebrew/Bottles/erlang-R15B-bottle.tar.gz',
|
|
|
|
'R15B'
|
|
|
|
end
|
|
|
|
|
2011-09-21 17:14:54 -05:00
|
|
|
def test_imagemagick_bottle_style
|
|
|
|
check 'http://downloads.sf.net/project/machomebrew/Bottles/imagemagick-6.7.1-1-bottle.tar.gz',
|
|
|
|
'6.7.1-1'
|
|
|
|
end
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|