test_tab: add test for Tab#spec
Fixes Homebrew/homebrew#42147. Closes Homebrew/homebrew#42205. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
		
							parent
							
								
									a9e71ca905
								
							
						
					
					
						commit
						8054161153
					
				
							
								
								
									
										8
									
								
								Library/Homebrew/test/fixtures/receipt.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								Library/Homebrew/test/fixtures/receipt.json
									
									
									
									
										vendored
									
									
								
							@ -9,9 +9,13 @@
 | 
			
		||||
  ],
 | 
			
		||||
  "built_as_bottle": false,
 | 
			
		||||
  "poured_from_bottle": true,
 | 
			
		||||
  "tapped_from": "Homebrew/homebrew",
 | 
			
		||||
  "time": 1403827774,
 | 
			
		||||
  "HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
 | 
			
		||||
  "stdlib": "libcxx",
 | 
			
		||||
  "compiler": "clang"
 | 
			
		||||
  "compiler": "clang",
 | 
			
		||||
  "source": {
 | 
			
		||||
      "path": "/usr/local/Library/Formula/foo.rb",
 | 
			
		||||
      "tap": "Homebrew/homebrew",
 | 
			
		||||
      "spec": "stable"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								Library/Homebrew/test/fixtures/receipt_old.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								Library/Homebrew/test/fixtures/receipt_old.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
{
 | 
			
		||||
  "used_options": [
 | 
			
		||||
    "--with-foo",
 | 
			
		||||
    "--without-bar"
 | 
			
		||||
  ],
 | 
			
		||||
  "unused_options": [
 | 
			
		||||
    "--with-baz",
 | 
			
		||||
    "--without-qux"
 | 
			
		||||
  ],
 | 
			
		||||
  "built_as_bottle": false,
 | 
			
		||||
  "poured_from_bottle": true,
 | 
			
		||||
  "tapped_from": "Homebrew/homebrew",
 | 
			
		||||
  "time": 1403827774,
 | 
			
		||||
  "HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
 | 
			
		||||
  "stdlib": "libcxx",
 | 
			
		||||
  "compiler": "clang"
 | 
			
		||||
}
 | 
			
		||||
@ -19,6 +19,7 @@ class TabTests < Homebrew::TestCase
 | 
			
		||||
      "source"             => {
 | 
			
		||||
        "tap" => "Homebrew/homebrew",
 | 
			
		||||
        "path" => nil,
 | 
			
		||||
        "spec" => "stable",
 | 
			
		||||
      },
 | 
			
		||||
    })
 | 
			
		||||
  end
 | 
			
		||||
@ -66,6 +67,22 @@ class TabTests < Homebrew::TestCase
 | 
			
		||||
    assert_predicate @tab, :poured_from_bottle
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_from_old_version_file
 | 
			
		||||
    path = Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt_old.json")
 | 
			
		||||
    tab = Tab.from_file(path)
 | 
			
		||||
 | 
			
		||||
    assert_equal @used.sort, tab.used_options.sort
 | 
			
		||||
    assert_equal @unused.sort, tab.unused_options.sort
 | 
			
		||||
    refute_predicate tab, :built_as_bottle
 | 
			
		||||
    assert_predicate tab, :poured_from_bottle
 | 
			
		||||
    assert_equal "Homebrew/homebrew", tab.tap
 | 
			
		||||
    assert_equal :stable, tab.spec
 | 
			
		||||
    refute_nil tab.time
 | 
			
		||||
    assert_equal TEST_SHA1, tab.HEAD
 | 
			
		||||
    assert_equal :clang, tab.cxxstdlib.compiler
 | 
			
		||||
    assert_equal :libcxx, tab.cxxstdlib.type
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_from_file
 | 
			
		||||
    path = Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt.json")
 | 
			
		||||
    tab = Tab.from_file(path)
 | 
			
		||||
@ -75,6 +92,7 @@ class TabTests < Homebrew::TestCase
 | 
			
		||||
    refute_predicate tab, :built_as_bottle
 | 
			
		||||
    assert_predicate tab, :poured_from_bottle
 | 
			
		||||
    assert_equal "Homebrew/homebrew", tab.tap
 | 
			
		||||
    assert_equal :stable, tab.spec
 | 
			
		||||
    refute_nil tab.time
 | 
			
		||||
    assert_equal TEST_SHA1, tab.HEAD
 | 
			
		||||
    assert_equal :clang, tab.cxxstdlib.compiler
 | 
			
		||||
@ -88,6 +106,7 @@ class TabTests < Homebrew::TestCase
 | 
			
		||||
    assert_equal @tab.built_as_bottle, tab.built_as_bottle
 | 
			
		||||
    assert_equal @tab.poured_from_bottle, tab.poured_from_bottle
 | 
			
		||||
    assert_equal @tab.tap, tab.tap
 | 
			
		||||
    assert_equal @tab.spec, tab.spec
 | 
			
		||||
    assert_equal @tab.time, tab.time
 | 
			
		||||
    assert_equal @tab.HEAD, tab.HEAD
 | 
			
		||||
    assert_equal @tab.compiler, tab.compiler
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user