aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorAlyssa Ross2016-12-31 13:14:27 +0000
committerAlyssa Ross2016-12-31 17:53:06 +0000
commit8b30abe0600df5c9d3da5b4c31ca88a71a1c3e03 (patch)
tree6f4d26a070a713250b62410eed0aa6e169e8bfdf /Library/Homebrew/test
parent9fa95d721820919eff3193c3c5bded37f6589831 (diff)
downloadbrew-8b30abe0600df5c9d3da5b4c31ca88a71a1c3e03.tar.bz2
keg: handle dependencies of moved/renamed formulae
In #1497 I switched from Keg#to_formula for comparing kegs to formulae to comparing the name and tap in the keg's tab to the name and tap of the formula. However, this fails to match if the name and tap of the formula have changed since the keg was installed, so it's clearly better to use Keg#to_formula where possible, and fall back to the information in the tab when #to_formula can't be used.
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/keg_test.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb
index 45d63aa95..40beac887 100644
--- a/Library/Homebrew/test/keg_test.rb
+++ b/Library/Homebrew/test/keg_test.rb
@@ -373,6 +373,7 @@ class InstalledDependantsTests < LinkTestCase
t.source["tap"] = "some/tap"
t.source["path"] = nil
end
+
dependencies [{ "full_name" => "some/tap/foo", "version" => "1.0" }]
assert_equal [@dependent], @keg.installed_dependents
assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg])
@@ -388,7 +389,7 @@ class InstalledDependantsTests < LinkTestCase
Formula["bar"].class.depends_on "baz"
result = Keg.find_some_installed_dependents([@keg, @tap_dep])
- assert_equal [[@tap_dep], ["bar"]], result
+ assert_equal [[@keg, @tap_dep], ["bar"]], result
end
def test_no_dependencies_anywhere
@@ -411,6 +412,23 @@ class InstalledDependantsTests < LinkTestCase
assert_nil Keg.find_some_installed_dependents([@keg, @dependent])
end
+ def test_renamed_dependency
+ dependencies nil
+
+ stub_formula_loader Formula["foo"], "homebrew/core/foo-old"
+ renamed_path = HOMEBREW_CELLAR/"foo-old"
+ (HOMEBREW_CELLAR/"foo").rename(renamed_path)
+ renamed_keg = Keg.new(renamed_path.join("1.0"))
+
+ Formula["bar"].class.depends_on "foo"
+
+ result = Keg.find_some_installed_dependents([renamed_keg])
+ assert_equal [[renamed_keg], ["bar"]], result
+ ensure
+ # Move it back to where it was so it'll be cleaned up.
+ (HOMEBREW_CELLAR/"foo-old").rename(HOMEBREW_CELLAR/"foo")
+ end
+
def test_empty_dependencies_in_tab
dependencies []
assert_empty @keg.installed_dependents