Test source.path on Tab.create and .for_formula

This commit is contained in:
Alyssa Ross 2016-09-07 22:52:25 +01:00
parent f9e16ee2e0
commit 4f1d47bc15
2 changed files with 36 additions and 2 deletions

View File

@ -121,6 +121,40 @@ class TabTests < Homebrew::TestCase
assert_equal source_path, tab.source["path"]
end
def test_create
f = formula { url "foo-1.0" }
compiler = DevelopmentTools.default_compiler
stdlib = :libcxx
tab = Tab.create(f, compiler, stdlib)
assert_equal f.path.to_s, tab.source["path"]
end
def test_create_from_alias
alias_path = CoreTap.instance.alias_dir/"bar"
f = formula(:alias_path => alias_path) { url "foo-1.0" }
compiler = DevelopmentTools.default_compiler
stdlib = :libcxx
tab = Tab.create(f, compiler, stdlib)
assert_equal f.alias_path.to_s, tab.source["path"]
end
def test_for_formula
f = formula { url "foo-1.0" }
tab = Tab.for_formula(f)
assert_equal f.path.to_s, tab.source["path"]
end
def test_for_formula_from_alias
alias_path = CoreTap.instance.alias_dir/"bar"
f = formula(:alias_path => alias_path) { url "foo-1.0" }
tab = Tab.for_formula(f)
assert_equal alias_path.to_s, tab.source["path"]
end
def test_to_json
tab = Tab.new(Utils::JSON.load(@tab.to_json))
assert_equal @tab.used_options.sort, tab.used_options.sort

View File

@ -72,8 +72,8 @@ module Homebrew
TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, &block)
@_f = Class.new(Formula, &block).new(name, path, spec)
def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, alias_path: nil, &block)
@_f = Class.new(Formula, &block).new(name, path, spec, :alias_path => alias_path)
end
def mktmpdir(prefix_suffix = nil, &block)