more test for dependency_expansion

Closes Homebrew/homebrew#48904.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2016-02-06 14:14:41 +08:00
parent 8749ecc383
commit f57950404b

View File

@ -115,4 +115,20 @@ class DependencyExpansionTests < Homebrew::TestCase
assert_equal [@foo, @bar, @baz, @qux], @f.deps assert_equal [@foo, @bar, @baz, @qux], @f.deps
assert_equal [@bar, @baz], Dependency.expand(@f, [@bar, @baz]) assert_equal [@bar, @baz], Dependency.expand(@f, [@bar, @baz])
end end
def test_cyclic_dependency
foo = build_dep(:foo)
bar = build_dep(:bar, [], [foo])
foo.stubs(:to_formula).returns(stub(:deps => [bar], :name => "foo"))
f = stub(:name => "f", :deps => [foo, bar])
assert_nothing_raised { Dependency.expand(f) }
end
def test_clean_expand_stack
foo = build_dep(:foo)
foo.stubs(:to_formula).raises(FormulaUnavailableError, "foo")
f = stub(:name => "f", :deps => [foo])
assert_raises(FormulaUnavailableError) { Dependency.expand(f) }
assert_empty Dependency.instance_variable_get(:@expand_stack)
end
end end