Another version test

This commit is contained in:
Max Howell 2009-06-08 15:57:24 +01:00
parent 0997a04bf8
commit 9003225a34
2 changed files with 22 additions and 7 deletions

View File

@ -57,15 +57,25 @@ end
# pass in the basename of the filename _without_ any file extension
def extract_version basename
# eg. foobar4.5.1
# eg. foobar-4.5.1
# eg. foobar-4.5.1b
/^[^0-9]*((\d+\.)*(\d+-)?\d+[abc]?)$/.match basename
# eg. boost_1_39_0
/((\d+_)+\d+)$/.match basename
return $1.gsub('_', '.') if $1
# eg. foobar-4.5.1-1
/-((\d+\.)*\d+-\d+)$/.match basename
return $1 if $1
# eg. boost_1_39_0
/^[^0-9]*((\d+_)*\d+)$/.match basename
return $1.gsub('_', '.') if $1
# eg. foobar-4.5.1
/-((\d+\.)*\d+)$/.match basename
return $1 if $1
# eg. foobar-4.5.1b
/-((\d+\.)*\d+[abc])$/.match basename
return $1 if $1
# eg. foobar4.5.1
/((\d+\.)*\d+)$/.match basename
return $1 if $1
# eg. (erlang) otp_src_R13B
/^.*[-_.](.*)$/.match basename

View File

@ -34,6 +34,11 @@ class BeerTasting <Test::Unit::TestCase
assert_equal 'R13B', r.version
end
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
def test_version_internal_dash
r=TestFormula.new "http://example.com/foo-arse-1.1-2.tar.gz"
assert_equal '1.1-2', r.version