 6008187d5f
			
		
	
	
		6008187d5f
		
	
	
	
	
		
			
			In order to allow kegs built with the same version but differing formula revisions to coexist, we must encode the revision as part of the keg's name. This is necessary to actually perform an upgrade, as we cannot upgrade a keg in-place, and temporarily moving it pending the result of the upgrade is error-prone and potentially slow. To accomplish this, we introduce a new Formula#pkg_version method that concatenates the active_spec version with the formula revision. An exception is made for a formula that has no revision: the tag is omitted. This preserves compatibility with existing installations.
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require 'testing_env'
 | |
| require 'pkg_version'
 | |
| 
 | |
| class PkgVersionTests < Test::Unit::TestCase
 | |
|   def v(version)
 | |
|     PkgVersion.parse(version)
 | |
|   end
 | |
| 
 | |
|   def test_parse
 | |
|     assert_equal PkgVersion.new("1.0", 1), PkgVersion.parse("1.0_1")
 | |
|     assert_equal PkgVersion.new("1.0", 1), PkgVersion.parse("1.0_1")
 | |
|     assert_equal PkgVersion.new("1.0", 0), PkgVersion.parse("1.0")
 | |
|     assert_equal PkgVersion.new("1.0", 0), PkgVersion.parse("1.0_0")
 | |
|     assert_equal PkgVersion.new("2.1.4", 0), PkgVersion.parse("2.1.4_0")
 | |
|     assert_equal PkgVersion.new("2.1.4_1", 0), PkgVersion.parse("2.1.4_1_0")
 | |
|     assert_equal PkgVersion.new("1.0.1e", 1), PkgVersion.parse("1.0.1e_1")
 | |
|   end
 | |
| 
 | |
|   def test_comparison
 | |
|     assert_operator v("1.0_0"), :==, v("1.0")
 | |
|     assert_operator v("1.0_1"), :==, v("1.0_1")
 | |
|     assert_operator v("1.1"), :>, v("1.0_1")
 | |
|     assert_operator v("1.0_0"), :==, v("1.0")
 | |
|     assert_operator v("1.0_1"), :<, v("2.0_1")
 | |
|     assert_operator v("HEAD"), :>, v("1.0")
 | |
|     assert_operator v("1.0"), :<, v("HEAD")
 | |
|   end
 | |
| 
 | |
|   def test_to_s
 | |
|     assert_equal "1.0", PkgVersion.new("1.0", 0).to_s
 | |
|     assert_equal "1.0_1", PkgVersion.new("1.0", 1).to_s
 | |
|     assert_equal "1.0", PkgVersion.new("1.0", 0).to_s
 | |
|     assert_equal "1.0", PkgVersion.new("1.0", 0).to_s
 | |
|     assert_equal "HEAD", PkgVersion.new("HEAD", 1).to_s
 | |
|   end
 | |
| end
 |