aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorAlyssa Ross2016-11-13 23:17:40 +0000
committerAlyssa Ross2016-11-13 23:20:38 +0000
commitf7f72093a80aade07d9b1da7f1e64dadcb5bd62b (patch)
tree2870799578e88151d9d0b40cd7946d3d78fbaf81 /Library/Homebrew/test
parent0f6cd9d7a51108497974cae52f177c9a8c57c0ed (diff)
downloadbrew-f7f72093a80aade07d9b1da7f1e64dadcb5bd62b.tar.bz2
keg: don't rely on #to_formula
It doesn't always work. For example, a keg could have been installed with a formula from a URL, which Homebrew now does not know how to access. Fixes #1496.
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/test_keg.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/Library/Homebrew/test/test_keg.rb b/Library/Homebrew/test/test_keg.rb
index 7450d9c0f..fdc739c9d 100644
--- a/Library/Homebrew/test/test_keg.rb
+++ b/Library/Homebrew/test/test_keg.rb
@@ -317,12 +317,16 @@ end
class InstalledDependantsTests < LinkTests
def stub_formula_name(name)
- stub_formula_loader formula(name) { url "foo-1.0" }
+ f = formula(name) { url "foo-1.0" }
+ stub_formula_loader f
+ stub_formula_loader f, "homebrew/core/#{f}"
+ f
end
def setup_test_keg(name, version)
- stub_formula_name(name)
+ f = stub_formula_name(name)
keg = super
+ Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
Formula.clear_cache
keg
end
@@ -345,6 +349,17 @@ class InstalledDependantsTests < LinkTests
end
end
+ # Test with a keg whose formula isn't known.
+ # This can happen if e.g. a formula is installed
+ # from a file path or URL.
+ def test_unknown_formula
+ Formulary.unstub(:loader_for)
+ dependencies []
+ alter_tab { |t| t.source["path"] = nil }
+ assert_empty @keg.installed_dependents
+ assert_nil Keg.find_some_installed_dependents([@keg])
+ end
+
def test_no_dependencies_anywhere
dependencies nil
assert_empty @keg.installed_dependents