2009-05-21 00:04:43 +01:00
|
|
|
#!/usr/bin/ruby
|
2009-06-05 12:57:37 +01:00
|
|
|
|
2009-06-05 23:39:56 +01:00
|
|
|
$:.unshift File.dirname(__FILE__)
|
2009-05-21 00:04:43 +01:00
|
|
|
require 'test/unit'
|
2009-06-05 12:57:37 +01:00
|
|
|
require 'brewkit'
|
2009-06-15 01:16:00 +01:00
|
|
|
require 'stringio'
|
2009-06-02 13:39:39 +01:00
|
|
|
|
|
|
|
class TestFormula <Formula
|
2009-06-05 23:39:56 +01:00
|
|
|
def initialize url, md5='nomd5'
|
2009-06-02 13:39:39 +01:00
|
|
|
@url=url
|
|
|
|
@md5=md5
|
2009-06-05 23:39:56 +01:00
|
|
|
super 'test'
|
2009-06-02 13:39:39 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-06-15 01:16:00 +01:00
|
|
|
def nostdout
|
|
|
|
tmp=$stdout
|
|
|
|
$stdout=StringIO.new
|
|
|
|
yield
|
|
|
|
$stdout=tmp
|
|
|
|
end
|
|
|
|
|
2009-06-02 13:39:39 +01:00
|
|
|
|
|
|
|
class BeerTasting <Test::Unit::TestCase
|
2009-05-21 00:04:43 +01:00
|
|
|
def test_version_all_dots
|
2009-06-05 23:39:56 +01:00
|
|
|
r=TestFormula.new "http://example.com/foo.bar.la.1.14.zip"
|
2009-05-21 00:04:43 +01:00
|
|
|
assert_equal '1.14', r.version
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_version_underscore_separator
|
2009-06-05 23:39:56 +01:00
|
|
|
r=TestFormula.new "http://example.com/grc_1.1.tar.gz"
|
2009-05-21 00:04:43 +01:00
|
|
|
assert_equal '1.1', r.version
|
|
|
|
end
|
|
|
|
|
2009-06-05 23:39:56 +01:00
|
|
|
def test_boost_version_style
|
|
|
|
r=TestFormula.new "http://example.com/boost_1_39_0.tar.bz2"
|
2009-05-25 11:57:12 +01:00
|
|
|
assert_equal '1.39.0', r.version
|
|
|
|
end
|
|
|
|
|
2009-06-05 23:39:56 +01:00
|
|
|
def test_erlang_version_style
|
|
|
|
r=TestFormula.new "http://erlang.org/download/otp_src_R13B.tar.gz"
|
|
|
|
assert_equal 'R13B', r.version
|
|
|
|
end
|
2009-06-08 15:57:24 +01:00
|
|
|
|
2009-06-15 00:54:58 +01:00
|
|
|
def test_astyle_verson_style
|
|
|
|
r=TestFormula.new "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz"
|
|
|
|
assert_equal '1.23', r.version
|
|
|
|
end
|
|
|
|
|
2009-06-18 09:52:38 +01:00
|
|
|
def test_version_libvorbis
|
|
|
|
r=TestFormula.new "http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2rc1.tar.bz2"
|
|
|
|
assert_equal '1.2.2rc1', r.version
|
|
|
|
end
|
|
|
|
|
2009-06-08 15:57:24 +01:00
|
|
|
def test_dos2unix
|
|
|
|
r=TestFormula.new "http://www.sfr-fresh.com/linux/misc/dos2unix-3.1.tar.gz"
|
|
|
|
assert_equal '3.1', r.version
|
|
|
|
end
|
2009-06-05 23:39:56 +01:00
|
|
|
|
2009-05-21 00:04:43 +01:00
|
|
|
def test_version_internal_dash
|
2009-06-05 23:39:56 +01:00
|
|
|
r=TestFormula.new "http://example.com/foo-arse-1.1-2.tar.gz"
|
2009-05-21 00:04:43 +01:00
|
|
|
assert_equal '1.1-2', r.version
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_version_single_digit
|
2009-06-05 23:39:56 +01:00
|
|
|
r=TestFormula.new "http://example.com/foo_bar.45.tar.gz"
|
2009-05-21 00:04:43 +01:00
|
|
|
assert_equal '45', r.version
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_noseparator_single_digit
|
2009-06-05 23:39:56 +01:00
|
|
|
r=TestFormula.new "http://example.com/foo_bar45.tar.gz"
|
2009-05-21 00:04:43 +01:00
|
|
|
assert_equal '45', r.version
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_version_developer_that_hates_us_format
|
2009-06-05 23:39:56 +01:00
|
|
|
r=TestFormula.new "http://example.com/foo-bar-la.1.2.3.tar.gz"
|
2009-05-21 00:04:43 +01:00
|
|
|
assert_equal '1.2.3', r.version
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_version_regular
|
2009-06-05 23:39:56 +01:00
|
|
|
r=TestFormula.new "http://example.com/foo_bar-1.21.tar.gz"
|
2009-05-21 00:04:43 +01:00
|
|
|
assert_equal '1.21', r.version
|
|
|
|
end
|
|
|
|
|
2009-06-02 13:39:39 +01:00
|
|
|
def test_yet_another_version
|
2009-06-05 23:39:56 +01:00
|
|
|
r=TestFormula.new "http://example.com/mad-0.15.1b.tar.gz"
|
2009-06-02 13:39:39 +01:00
|
|
|
assert_equal '0.15.1b', r.version
|
|
|
|
end
|
|
|
|
|
2009-06-05 23:39:56 +01:00
|
|
|
def test_supported_compressed_types
|
|
|
|
assert_nothing_raised do
|
|
|
|
TestFormula.new 'test-0.1.tar.gz'
|
|
|
|
TestFormula.new 'test-0.1.tar.bz2'
|
|
|
|
TestFormula.new 'test-0.1.tgz'
|
|
|
|
TestFormula.new 'test-0.1.zip'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-05-21 00:04:43 +01:00
|
|
|
def test_prefix
|
|
|
|
url='http://www.methylblue.com/test-0.1.tar.gz'
|
|
|
|
md5='d496ea538a21dc4bb8524a8888baf88c'
|
2009-06-15 01:16:00 +01:00
|
|
|
|
|
|
|
nostdout do
|
|
|
|
TestFormula.new(url, md5).brew do |f|
|
|
|
|
assert_equal File.expand_path(f.prefix), ($cellar+f.name+'0.1').to_s
|
|
|
|
assert_kind_of Pathname, f.prefix
|
|
|
|
end
|
2009-05-21 00:04:43 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|