| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2010-01-29 10:41:03 -08:00
										 |  |  | end |